/**
 * IM 接口说明：
 * 
 * 1.当前用户ID，IM服务器会尝试从Cookie获取UID，如果不能取到，会尝试从请求参数uid获取。
 * 2.服务器提供的不同命令包括：
 * 		a. msg （地址 /msg）用于一个用户向另一个用户发送消息。
 * 			需要的参数有：tuid 消息发给那个用户
 * 						 msg：消息的内容
 * 						 uid：用户id，可选
 * 						 lid:用户的验证cookie，同电子圈的LID（以下如果因权限不能发送成功均需携带lid）
 * 			
 * 		a+. group msg （地址 /gmsg）用于一个用户向一个聊天群发送消息。
 * 			需要的参数有：gid 消息发给这个群
 * 						 msg：消息的内容
 * 						 uid：用户id，可选
 * 						 lid:用户的验证cookie，同电子圈的LID 

 * 		
 * 			返回：操作成功后返回空对象 {}
 * 	
 * 		b. cmd （地址 /cmd）用于发送用户自己的控制消息，比如打开了聊天窗口，控制所有会话中界面一致。
 * 				适用于web，客户端可以不用
 * 			需要的参数：
 * 					 msg：消息的内容
 * 					 uid：用户id，可选
 * 					
 * 					 type:命令的类型
 *			   				0:Default, //聊天消息
							1:StatusChang, //在线状态改变
							2:Control,//自己的消息
								web客户端 发送函数到服务器端，服务器发给自己的其他桌面
								比如 ：msg的值为 { fun:'IM.chatTo(123,true)'} 
							3:Group//群聊消息
 * 		c. pull（地址 /pull）用户从服务器端拖即使消息。如果拖不到会一直等着。
 *  		需要的参数
 *  			key：客户端生成的随机整数，代表一个唯一的会话。一个用户可以维护多个会话
 *  			from：下一条消息的id，避免漏包
 *  			uid：用户id，可选
 *  			lid:用户的验证cookie，同电子圈的LID
 *  			at:agent type,客户端类型
 *  					0 ：WebBrowser, 默认值
						1：Mobile, 不推送用户状态改变消息和自己的消息
	 
 *  		pull返回的结果：
 *  			from: 消息来源的用户id
 *  			to：消息发给谁，如果是群组类型的消息,值为群组id，否则应该为当前用户的id（但用处不大），
 *  			type：	消息类型
 *  					0：为普通对话消息
 *  					1.状态改变消息
 *  					2：控制消息，自己发送给自己的消息,如果是控制消息，content为对象
 *  					3.群聊消息
 *  			id：消息的序列号，在一次回话中，从1开始一直递增
 *    			content：消息的内容
 *    				type=0时，为普通字符串
 *    				type=1时，为对象，包括以下字段
 *    					好友状态改变： 
 *    							{fun:'IM.OSC(uid,status)'}
 *    							其中uid：好友id，
 *    								status：为改变后的状态
 *    					打开于对应用户的聊天窗口
 *    							{ fun:'IM.chatTo(123,true)'} 
 *    							//使用key过滤掉自己的消息，fun用于执行的函数
 *  
 *  	d.list （地址 /list）从服务器获取好友列表
 *  		需要的参数：
 *  		返回的结果需要包括：
 *  
 *  	d+ .group list （地址 /glist）从服务器获取好友列表
 *  		需要的参数：
 *  			gid 获取这个群的成员列表。由于群成员的分散性，群成员状态改变时，可重拖，而不是推送更新
 *  		返回的结果需要包括：
 *  
 *   *  
 *  
 *  	e. uinfo （地址 /uinfo） 从服务器获取一个用户的头像等信息
 *  		需要的参数
 *  			uid：用户id，用来做验证，知道那个用户查的
 *  			quid：被查询的用户的id
 *  
 *      f. login 地址(/login) 用户登录
 *      	需要的参数 
 *      		email:用户的email
 *      		pwd:用户的密码（暂时明文）
 *      
 *      	返回：
 *      		如果登录成功 {uid:54321,lid:"139434344-434343233"}
 *      		如果失败 {msg:"错误原因"}
 */ 


var IM = {
	fromIndex : 0,
	userId : 1, // TODO 这里如果是游客的话,就不能显示聊天窗口了.以后需要改为0
	urlbase:"http://im.dianziq.com",
	imgbase:"http://192.168.1.29/wendaimg/",
	msgurl:"/wenda/notify/msg.action",
	soundurl:"/wenda/img/webim/notify.wav",
    fileserver:"http://img.dianziq.com/wendaimg/",
    webroot:"/wenda",
    //chatGroup:[{"name":"技术讨论","img":"/web/img/group.jpg","id":"12541",
    			//"member":[
    			          //{"uid":"25561","img":"http://192.168.1.29:8851/s_male.png","name":"dlee_lida"},
    			          //{"uid":"23546","img":"http://192.168.1.29:8851/s_a493d1724887bee933d011369c27f9a55ebc41bf.jpg","name":"张三"}
    			//]
    		//}],
    chatGroup:[],
    chatGroupUser:[],
	lid:0,
	key : parseInt(Math.random() * 10000000),
	friends : [],
	strangers:[],
	onlineCount : 0,//在线数
	userInfo:{},
	shines:[],//用于保存收到消息闪烁的列表
	needCtl:true,//发送时是否需要按住ctl键，如果false直接enter发送
	faceHash:[],
    emojiHash:[],
    unReadMsg:[],  //未读消息
	isChating:false,//当前是否打开了聊天窗口
	requestCode:0,//请求编码
	pull : function() {// 发出一个连接
		setTimeout(function(){ IM.doPull();},10);
	},	
	
	debug:function(msg){
	//	alert(msg);
	},
	//private 
	doPull:function(){
		$.ajax({
			method : "get",
			url : IM.urlbase + "/msg/pull",
			scriptCharset : "utf-8",
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",
			data : {
				lid:this.lid,
				uid : this.userId,
				from : this.fromIndex,
				key : this.key
			},
		    dataType :"jsonp",
		    jsonpCallback:"IM.onMsg" // 响应回来之后需调用onMsg方法
		})
		 .done(function(status, nativeStatusText, responses, headers) {
			  IM.pull();
		 })
		 .fail(function(status, nativeStatusText, responses, headers) {
			 if(IM.requestCode!=0){
				 IM.pull();
			 }else{
				 //出错后延时调用
				 setTimeout(function(){
					 IM.pull();
				 },3000);
			 }
		 });
		 
		/*$.get(
				"../pull?key=" + this.key + "&uid=" + this.userId + "&from="
						+ this.fromIndex, function(data) {

					try {
						eval("var msg=" + data);
					} catch (e) {
						alert(e.message);
					}
					  
					IM.onMsg(msg);
					IM.pull();
				}).error(function() {
			setTimeout(function() {
				IM.pull()
			}, 5000);

		})*/
	},
	onMsg : function(msg) {
		try{
			IM.requestCode = msg.code;
            if(msg.code!=0){
		        return;
		    }

			if(msg.messages.length>1 || msg.recentMessageSize){
			    var messages = msg.messages;
				if(messages.length>1){
                    messages.sort(function(v1, v2) { // 服务器端使用环形数组，没排序
					 	return    v1.id-v2.id;
					});
				}
				//var isFirst=false;
				var backup=this.isChating;
				if(this.fromIndex==0){
					this.isChating=true;
				}
				for(var i=0;i<messages.length;i++){
					var m=messages[i];
					this.fromIndex=m.id;
					if(msg.fromIndex==0 && m.type==2){ //忽略控制消息
						continue;
					}
					this.doMsg(m,true);
				}
				 
				this.isChating=backup;
			}else if(msg.messages.length==1){
				this.doMsg(msg.messages[0]);
			}
		}catch(e){
			alert("处理消息时出错："+e.message);
		};
		//this.pull();
	},
	// 显示消息内容msg:json
	doMsg : function(msg,silence) {
		this.fromIndex=parseInt(msg.id);
		if (msg.type != 0) { // 控制指令 或状态改变
			var o = msg.content;
			if (o.key == this.key) { // 自己发出的消息
				return;
			}
            if(msg.type==1){
				this.OSC(o.uid, o.status);
				return;
			}
			if(msg.type==2 && o!='0'){
                var cmd=eval(o);
				eval(cmd);
				return;
			}
            if(msg.type==4){
                this.onUnreadInfo(o.newMsgCount, o.newNotifyCount);
				return;
			}
            //群聊
            if(msg.type==3){
        			$.ajax({
        		    	method : "get",
        		    	async:false,
        		    	url : IM.urlbase + "/user/info",
        		    	scriptCharset : "utf-8",
        		    	contentType : "application/x-www-form-urlencoded; charset=UTF-8",
        		    	data : {uid:this.userId,lid:this.lid,quid:msg.from},
        		    	dataType : "jsonp",
        		    	jsonpCallback:"IM.searchUserInfo" // 响应回来之后需调用onMsg方法
        	    	});
        			
        			setTimeout(function(){
        				if(msg.from == IM.userId){
        					var mc = IM.parseMsg(msg);            
        					var s='<dd class="wbim_msgr"><div class="wbim_msgpos"><div class="msg_time">'+User.name+'&nbsp&nbsp'+ IM.formatTime('m-d h:M');
        					s+='</div><div class="msg_box"><p class="txt">'+ mc +'</p></div><div class="msg_arr"></div></div></dd>';
        					var ele = IM.getChatListById(msg.to);
        					ele.append(s);
        					ele.parent().scrollTop(100000);
        				}else{
	        				var activeid = IM.getActiveTab().attr("uid");
	            			//if ((!silence)&&( msg.to != activeid)) {
	            			if (msg.to != activeid) {
	            				var a = IM.getTabById(msg.to);
	            				if (a.length == 0) {
	            					IM.addTab(IM.getGroup(msg.to), "wbim_active","group");
	            				}
                                if(!silence){
	            				    IM.shines.push(IM.getTabById(msg.to));
                                }
	            			}
	                        
	                        if(msg.to == activeid){
	                        	IM.updatePushStatus(msg.seq);
	                        }else{
	                            if(msg.status==0){
	                            	IM.unReadMsg.push(msg.seq);
	                            }
	                        }
	            			var mc = IM.parseMsg(msg);
	            		    //var mc=msg.content;
	            			//mc=this.replaceMsg(mc);
	            			var s='<dd class="wbim_msgl"><div class="wbim_msgpos"><div class="msg_time">'+ IM.userInfo.realname+'&nbsp&nbsp'+IM.formatTime('m-d h:M');
	            			s+='</div><div class="msg_box"><p class="txt">'+mc+'</p></div><div class="msg_arr"></div><span class="msg_arr_seq" style="display:none">'+msg.seq+'</span></div></dd>';
	            			ele = IM.getChatListById(msg.to);
	            			ele.append(s);
	            			ele.parent().scrollTop(100000);
	            		 
	            		
	            			if(!IM.isChating){
	            				
	            				$(".wbim_min_nick ").text("有新消息");
	            				//闪烁一下
	            				IM.shineMinChat();
	            			}
	            			$(".webim_msg_sd").attr("src",IM.soundurl);
        				}
        			},500);
        			
            }
			return;
		}
		// 自己的内容显示在右边,别人的内容在左边
		if (msg.from == this.userId) {// 自己
			var mc = this.parseMsg(msg);            
			var s='<dd class="wbim_msgr"><div class="wbim_msgpos"><div class="msg_time">'+User.name+'&nbsp&nbsp'+ this.formatTime('m-d h:M');
			s+='</div><div class="msg_box"><p class="txt">'+ mc +'</p></div><div class="msg_arr"></div></div></dd>';
			var ele = this.getChatListById(msg.to);
			ele.append(s);
			ele.parent().scrollTop(100000);
		} else if (msg.to == this.userId) {// 别人
			var sendUser=this.getUser(msg.from);
			if(!sendUser){//如果是陌生人，需要到服务器获取信息
				sendUser = this.fetchUser(msg.from);
			}
			
			var activeid = this.getActiveTab().attr("uid");
			if (msg.from != activeid) {
				var a = this.getTabById(msg.from);
				if (a.length == 0) {
					this.addTab(this.getUser(msg.from), " ");
				}
                if(!silence){
				    this.shines.push(this.getTabById(msg.from));
                }
			}
            
            if(msg.from == activeid){
                this.updatePushStatus(msg.seq);
            }else{
                if(msg.status==0){
                    this.unReadMsg.push(msg.seq);
                }
            }
			var mc = this.parseMsg(msg);
		    //var mc=msg.content;
			//mc=this.replaceMsg(mc);
			var s='<dd class="wbim_msgl"><div class="wbim_msgpos"><div class="msg_time">'+ sendUser.name+'&nbsp&nbsp'+this.formatTime('m-d h:M');
			s+='</div><div class="msg_box"><p class="txt">'+mc+'</p></div><div class="msg_arr"></div><span class="msg_arr_seq" style="display:none">'+msg.seq+'</span></div></dd>';
			ele = this.getChatListById(msg.from);
			ele.append(s);
			ele.parent().scrollTop(100000);
		 
		
			if(!this.isChating){
				
				$(".wbim_min_nick ").text("有新消息");
				//闪烁一下
				 this.shineMinChat();
			}
			$(".webim_msg_sd").attr("src",this.soundurl);
			//window.focus();
		}
	},
	zoom:function(img,e){//放大图片
		var _zoom = $("#zoom-pic"),e=e||event,x=e.clientX,y=e.clientY;
		var _orginPic = $(img).attr("lazy-load")||$(img).attr("src");
		if(_zoom.length>0){
			//如果点击的图片和之前已渲染的图片相同，则不需要再次加载直接显示
			if(_orginPic == $("#large-pic").attr("lazy-load")){
				if($("#zoom-pic").is(":hidden")){
					$("#zoom-pic").fadeIn("slow");
				}
				return;
			}else{
				//先移除，再操作
				$("#zoom-pic").remove();
			}
		}
		var _html = '<div id="zoom-pic" class="zoom-pic" style="opacity: 0;bottom:'+y+'px;right:'+x+'px"><div style="position:relative;">'+
			'<div id="pic-content" class="pic-content">'+
			'<div id="del_picture" class="del_picture"></div>'+
			'<img id="large-pic" src="'+IM.imgbase+_orginPic+'" lazy-load="'+_orginPic+'"></div></div></div>';
		$("#wbim_box").append(_html);
		//关闭层
		$("#del_picture").click(function(){
			$("#zoom-pic").animate({opacity: 0,bottom:y,right:x},500);
			$("#zoom-pic").remove();
		});
		$("#zoom-pic").dblclick(function(){
			$("#zoom-pic").animate({opacity: 0,bottom:y,right:x},500);
			$("#zoom-pic").remove();
		});
		$("#large-pic").load(function(){
			var _div = $("#pic-content");
			var _img = $("#large-pic");
			if(_img.height()>300){
				//当图片高度大于屏幕高度时
				if(_img.height()>=($(window).height()-50)){
					//调整div的高度
					_div.css("height",($(window).height()-50)+"px");
					//调整img的高度,不能让其越出div的高度
					_img.attr("height",($(window).height()-100)+"px");
				}else{
					_div.css("height",(_img.height()+50)+"px");
				}
			}else{
				_div.css("height","300px");
			}
			if(_img.width()>500){
				//当图片宽度大于屏幕宽度时
				if(_img.width()>=$(window).width()){
					//调整div的宽度
					_div.css("width",($(window).width()-100)+"px");
					//调整img的宽度,不能让其越出div的宽度
					_img.attr("width",($(window).width()-150)+"px");
				}else{
					_div.css("width",(_img.width()+100)+"px");
				}
			}else{
				_div.css("width","500px");
			}
			var _h = (_div.height()-_img.height())/2;
			$("#large-pic").css("margin-top",_h+"px");
		});
			//$("#zoom-pic").fadeIn("slow");
		//$("#zoom-pic").css({bottom:$(window).height()-y-$("#zoom-pic").outerHeight(),right:$(window).width()-x-$("#zoom-pic").outerWidth()});
		$("#zoom-pic").animate({opacity: 1,bottom:"1px",right:"1px"},500);
	},
	parseMsg:function(msg){
			var mc=msg.content;
            if(msg.ctype==1){
              mc = '<img ondblclick="IM.zoom(this)" src="'+IM.imgbase+'160x%3E_'+ mc+'" lazy-load="'+mc+'"/>';
            } else if(msg.ctype==0){
    			mc=this.replaceMsg(mc);
            }
            return mc;
        
	},

    /*默认是需要转义的*/
	replaceMsg:function(src, unescapeHtml){
		 var ret="";
		 for(var i=0;i<src.length;i++){
			 var si=src.charAt(i);
			 if(si=='['){
				 var j=src.indexOf("]",i);
				 if(j>0){
					 var c=src.substring(i,j+1);
					 var emjImg=this.emojiHash[c];
					 if(emjImg){
						 ret+="<img src="+this.getFaceImg(emjImg)+" />";
						 i=j;
						 continue;
					 }
				 }
			 }
             if(!unescapeHtml){
			    si=si=='\n'?"<br />":si=='&'?"&amp;":si=='<'?"&lt;":si=='\t'?"&nbsp;&nbsp;&nbsp;&nbsp;":si==' '?"&nbsp;":si=='>'?"&gt;":si;
             }
			 ret+=si;
				 
			 
		 }
		return ret;
	},
	sendJsonp : function(url, o) {
		$.ajax({
			method : "get",
			url : IM.urlbase + url,
			scriptCharset : "utf-8",
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",
			data : o,
			dataType : "jsonp"
		});
	},
	// 发送消息,默认文字消息type=0,图片type=1
	sendMsg : function(msg,type) {
		//当前聊天窗口的类型，如果窗口类型type为single则是点对点聊，如果type为group则是群聊天
		var _type = this.getActiveTab().attr("type");
		//如果_type为single则touid是好友id,如果type为group则touid为群id
		var touid = this.getActiveTab().attr("uid");
		if (!touid) {
			alert("Cannot find user");
			return;
		}
		var a = {};
		a.uid = this.userId;
		
		a.msg = msg;
		a.lid=this.lid;
		if(type){
			a.ctype = type;
		}
		if(_type == 'single'){
			//发送给好友
			a.tuid = touid;
			this.sendJsonp("/msg/send", a);
		}else if(_type == 'group'){
			//发送给群组
			a.tgid = touid;
			this.sendJsonp("/msg/send/group", a);
		}
	},
	// 发送控制命令
	sendCmd : function(obj) {
		var a = {};
		a.uid = this.userId;
		a.lid=this.lid;
		a.msg = obj;
		this.sendJsonp("/cmd", a);
	},
	// 更新消息状态
	// msgSeq 消息序号
	// 是否
	updatePushStatus : function(msgSeq, checkedUnRead) {
        if(checkedUnRead){
            //alert('uu='+this.unReadMsg);
            for (x in this.unReadMsg ){
               //alert('x='+this.unReadMsg[x]+",seq="+msgSeq+","+ (this.unReadMsg[x] == msgSeq))
               if(this.unReadMsg[x] == msgSeq){
                    this.updatePushStatus(msgSeq);
                    this.unReadMsg.splice(x,1);
                    break;
                }
            }
            return;
        }
		var a = {};
		a.uid = this.userId;
		a.lid=this.lid;
		a.msgSeq = msgSeq;
        a.status=2; //已读
		this.sendJsonp("/push/status/update", a);
	},

	// 渲染好友列表
	renderList : function(fri) {
		var _friends;
		if(fri){
			_friends = fri;
		}else{
			_friends = this.friends;
		}
		this.onlineCount = 0;
		this.getListUL().empty();
		try{
			_friends.sort(function(v1, v2) { // 好友排序
				
				if (v1.status == v2.status) {
					try{
					return v1.name - v2.name;
					}catch(e){
						return 0;
					}
				}
				return    v2.status-v1.status;
			});
		}catch(e){ this.debug(e.message); };
		for ( var i = 0; i < _friends.length; i++) {
			var f = _friends[i];
			var a="offline";
			if (f.status == 4) {
				this.onlineCount++;
				a = "online";
			}
			var li = '<li  class="wbim_'+a+'" onclick="IM.chatTo(' + f.id + ')" title="' + f.name + '" uid="' + f.id + '" >';
			li += '<div class="wbim_userhead"  >';
			li += '<img src="'+this.imgbase +"s_"+ f.img + '">';
			li += '<span style="DISPLAY: none" class="wbim_icon_msg_s"></span><span class="wbim_status_'+a+'"></span></div>';
			li += '<div class="wbim_username">' + f.name + '</div>';
			li += '</li>';
			this.getListUL().append(li);
		}
		$(".wbim_online_count").text(this.onlineCount );
		$("#wbim_list_group_frd div.wbim_list_group_tit span").text(this.onlineCount);
	
	},
	// 渲染聊天组列表
	renderGroup:function(){
		for ( var i in this.chatGroup) {
			var _g = this.chatGroup[i];
			var li = '<li   onclick="IM.chatToGroup(' + _g.gid + ')" title="' + _g.name + '" uid="' + _g.gid + '" >';
			li += '<div class="wbim_userhead"  >';
			li += '<img src="'+this.imgbase +"s_"+ _g.img + '">';
			li += '<span style="DISPLAY: none" class="wbim_icon_msg_s"></span></div>';
			li += '<div class="wbim_username">' + _g.name + '('+_g.ucnt+')</div>';
			li += '</li>';
			$("#wbim_list_group_group ul").append(li);
		}
	},
	// 显示聊天组中的用户
	renderGroupMember:function(g){
			//取聊天组中的成员
			var _member = g.users;
			for(var j in _member){
				var _m = _member[j];
				var a="offline";
				if (_m.status == 4) {
					a = "online";
				}
				var li = '<li  class="wbim_'+a+'" onclick="IM.chatTo(' + _m.uid + ')" title="' + _m.name + '" uid="' + _m.uid + '" >';
				li += '<div class="wbim_userhead"  >';
				li += '<img src="'+this.imgbase +"s_"+ _m.img + '">';
				li += '<span style="DISPLAY: none" class="wbim_icon_msg_s"></span><span class="wbim_status_'+a+'"></span></div>';
				li += '<div class="wbim_username">' + _m.name + '</div>';
				li += '</li>';
				$("#wbim_member ul").append(li);
			}

	},
	searchFriend:function(key){
		var tempFriend = [];
		for(var f in this.friends){
			var _name = this.friends[f].name;
			var py_name = this.friends[f].py_name;
			var py_name_1st = this.friends[f].py_name_1st;
			if(py_name.indexOf(key) != -1 || py_name_1st.indexOf(key) != -1 ||_name.indexOf(key) != -1){
				tempFriend.push(this.friends[f]);
			}
		}
		this.renderList(tempFriend);
	},
	// 从服务器读取好友集合
	fetchList : function() {
		$.ajax({
			method : "get",
			url : IM.urlbase + "/user/friends",
			scriptCharset : "utf-8",
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",
			data : {
				lid:this.lid,
				uid : this.userId
			},
			dataType : "jsonp",
			jsonpCallback : "IM.onList"
		})
		.fail(function() {
		});
	},
	// 从服务器读取聊天群组集合
	fetchGroupList : function() {
		$.ajax({
			method : "get",
			url : IM.urlbase + "/group/list",
			scriptCharset : "utf-8",
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",
			data : {
				lid:this.lid,
				uid : this.userId
			},
			dataType : "jsonp",
			jsonpCallback : "IM.onGroupList"
		})
		.fail(function() {
		});
	},
	// 从服务器读取聊天群组用户列表集合
	fetchGroupUserList : function(gid) {
		$.ajax({
			method : "get",
			url : IM.urlbase + "/group/users",
			scriptCharset : "utf-8",
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",
			data : {
				lid:this.lid,
				uid : this.userId,
				gid:gid
			},
			dataType : "jsonp",
			jsonpCallback : "IM.renderGroupMember"
		})
		.fail(function() {
		});
	},
	onUnreadInfo:function(msgCnt,notifyCnt){
		this.cookie("DZQ_MSGC", msgCnt);
		this.cookie("DZQ_NTFC", notifyCnt);
		
		if(msgCnt>0){
			$(".wbim_min_nick ").text("有 "+msgCnt+" 条离线消息");
			this.shineMinChat();
		}
	},
	//private
	shineMinChat:function(){
		this.minBox.attr("class", "wbim_min_box_col3");
		//闪烁一下
		this.minChat.addClass("wbim_min_chat_msg");
		setTimeout(function(){
			IM.minChat.removeClass("wbim_min_chat_msg");
		},300);
		setTimeout(function(){
			IM.minChat.addClass("wbim_min_chat_msg");
		},600);
		setTimeout(function(){
			IM.minChat.removeClass("wbim_min_chat_msg");
		},900);
		setTimeout(function(){
			IM.minChat.addClass("wbim_min_chat_msg");
		},1200);
	},
	onList:function(f){
        if(f.code!=0){
	        return;
	    }
		this.friends = f.friends;
		this.renderList();
	},
	onGroupList:function(f){
        if(f.code!=0){
	        return;
	    }
        this.chatGroup = f.groups;
		this.renderGroup();
	},
	//替换更新陌生人的资料
	onUInfo:function(f){
        if(f.code!=0){
	        return;
	    }
			var u=f;
			var ou=this.getUser(u.id);
			if(ou){
                
				ou.name=u.name;
				ou.img=u.img;
				var tab=this.getTabById(u.id);
				tab.find(".wbim_username").text(u.name);
				tab.find("img").attr("src",this.imgbase +"s_"+u.img);
			}
        /*
		for(var i=0;i<f.length;i++){
			var u=f[i];
			if(u){
				var ou=this.getUser(u.id);
				if(ou){
					ou.name=u.name;
					ou.img=u.img;
					var tab=this.getTabById(u.id);
					tab.find(".wbim_username").text(u.name);
					tab.find("img").attr("src",this.imgbase +"s_"+u.img);
					
					
			 	}
				
			}
			
		}
        */
	},
	//在线状态改变
	OSC : function(uid, status) {
		var f = this.getUser(uid);
		if (f) {
			f.status = status;
		}
		$(".wbim_chat_friend_list li[uid=" + uid + "] div span").attr("class",this.getStatusCssName(uid));
		//this.getChatListById(uid);
		if(parseInt( this.getActiveTab().attr("uid"))==uid ){
			this.updateOfflineTips(uid); 
			 
		}
		this.renderList();
	},
	// 获取单个好友信息
	getUser : function(uid) {
		for ( var i = 0; i < this.friends.length; i++) {
			if (this.friends[i].id == uid) {
				return this.friends[i];
			}
		}
		for ( var i = 0; i < this.strangers.length; i++) {
			if (this.strangers[i].id == uid) {
				return this.strangers[i];
			}
		}
		
		return null;
	},
	// 获取聊天群组信息
	getGroup : function(groupid) {
		for ( var i in this.chatGroup) {
			if (this.chatGroup[i].gid == groupid) {
				return this.chatGroup[i];
			}
		}
		return null;
	},
	isFriend:function(uid){
		for ( var i = 0; i < this.friends.length; i++) {
			if (this.friends[i].id == uid) {
				return true;
			}
		}
		return false;
	},
	// 获取好友的列表
	getListUL : function() {
		return $("#wbim_list_group_frd ul");
	},
	// 当前被激活的好友聊天窗口
	getActiveTab:function(){
		return $("ul.wbim_chat_friend_list .wbim_active");
	},
	// 获取聊天窗口第一个好友窗口
	getFirstTab:function(){
		return $("ul.wbim_chat_friend_list li:first-child");
	},
	// 根据uid获取好友的聊天窗口
	getTabById:function(id){
		return $("ul.wbim_chat_friend_list li[uid=\""+id+"\"]");
	},
	// 根据Id获取聊天记录
	getChatListById : function(id) {
		var u = $(".wbim_chat_list dl[uid=" + id + "]");
		if (u.length > 0) {// 之前就存在聊天记录
			return u;
		} else {
			this.chatConentList.append('<dl style="display:none" uid="' + id + '"></dl>');
		}
		return $(".wbim_chat_list dl[uid=" + id + "]");// 重新获取一次
	},
	activeTab : function(id, nottrigger) {
		var a = this.getActiveTab();
		if (a) {
			a.removeClass("wbim_active");
		}
		var at = this.getTabById(id);
		if (at) {
			at.addClass("wbim_active");
		}
		this.onActiveTabChange(nottrigger);
	},
	// 根据状态去CSS样式	
	getStatusCssName:function(uid){
		var stat = [ 
		            "wbim_status_offline" ,// 下线
		            "wbim_status_offline", //隐身
		            "wbim_status_busy",//忙碌
		            "wbim_status_away",  // 离开
		             "wbim_status_online"  // 在线
		               ];
		var u = this.getUser(uid); 
		if(!u){
			return stat[0];
		}
		return stat[u.status];
	}
	,
	onActiveTabChange : function(nottrigger) {
		var a = this.getActiveTab();
		if (a.length == 0) {
			alert("Error：Cannot find active tab");
			return;
		}
		var uid = a.attr("uid");//type="group"时uid为群组id,type="single"时uid为用户id
		var _type = a.attr("type");
		$(".wbim_chat_list dl").hide(); // 首先隐藏所有的聊天记录
		var ele = this.getChatListById(uid);
		ele.show();
		ele.parent().scrollTop(100000);
		this.getChatListById(uid).show(); // 显示与目标用户的聊天记录
        

		if (uid) {
			var name = '';
			if(_type == "group"){
				name = this.getGroup(uid).name; // 获取聊天群名称
			}else if(_type == "single"){
				name = this.getUser(uid).name; // 获取好友用户名
			}
			
			$(".wbim_min_nick ").text("正与 "+name+" 聊天中");// 正在与谁聊天的文字显示成当前的
			$("div.wbim_tit_lf p span:first-child").attr("class",this.getStatusCssName(uid));
			var tia=$(".wbim_tit_lf p span a");
			tia.text(name);
			tia.attr("href",this.webroot+"/user/userAction!getUser.action?currentId="+uid);
			
			$(".wbim_chat_toolbarin .wbim_history").attr("href", this.webroot+"/notify/msg!echoplex.action?uid="+this.userId+"&tuid="+uid+"&type=0" ); //TODO:fill all
			
			
			this.minChat.removeClass("wbim_min_chat_msg");
			this.removeShine(a);
			//不为群组tab时，更新好友离线提示
			if(_type == "group"){
				$(".wbim_chat_tips").hide();
			}else{
				this.updateOfflineTips(uid);
			}

            //更新消息为已读
			var chatListEle = this.getChatListById(uid);
            $.each(chatListEle.find('.wbim_msgl .wbim_msgpos .msg_arr_seq'), function(i,val){  
                var msgSeq = $(this).html();
                IM.updatePushStatus(msgSeq, true);
            });
			
		}
		if (nottrigger)
			return;
		if(_type == "group"){
			this.sendCmd('{ fun:"IM.chatToGroup(' + uid + ',true)"} ');
		}else{
			this.sendCmd('{ fun:"IM.chatTo(' + uid + ',true)"} ');
		}
	},
	updateOfflineTips:function(uid){
		var sp=$("span[node-type='wbim_chat_tips_content']");
		if(this.isFriend(uid)){
			sp.text("对方当前不在线或隐身，可能无法立即回复。");
			var s=this.getUser(uid).status;
		 	if(s==4){
				this.hiddeOffLineTips();
			}
			else{
				this.showOffLineTips();
			}
		}
		else{
//			sp.html("对方不是你的好友，不能看到在线状态。<a href='javascript:void' data-uid='"+uid+"' id='im_addfriend' >加好友</a>。");
            sp.html("对方不是你的好友，不能看到在线状态。");
			try{
			DzqFriend.reqFriend("#im_addfriend");
			}catch(e){alert(e.message)};
			this.showOffLineTips();
		}
		
	},
	//查询用户信息
	searchUserInfo:function(data){
		this.userInfo = data;
	},
	fetchUser:function(uid){
		 var a = {};
			a.uid = this.userId;
			a.quid = uid;
		    a.lid=this.lid;
			//this.sendJsonp("/user/info", a);
		    $.ajax({
		    	method : "get",
		    	url : IM.urlbase + "/user/info",
		    	scriptCharset : "utf-8",
		    	contentType : "application/x-www-form-urlencoded; charset=UTF-8",
		    	data : a,
		    	dataType : "jsonp",
		    	jsonpCallback : "IM.onUInfo"
	    	})
	    	.fail(function() {
	    	});

			var u={};
			u.id=uid;
			u.name="陌生人";
			u.img="male.png";
			u.status=0;
			this.strangers[this.strangers.length]=u;
			return u;
	},
	// nottrigger  不触发级联动作
	chatTo : function(uid,nottrigger) {
		$(".wbim_chat_ef").fadeOut();
		$(".wbim_chat_box").css("width","420px");
		$(".wbim_chat_box").fadeIn();
		var f = this.getUser(uid);
		if (f == null) {
			
			f=this.fetchUser(uid); 
		}
		if(this.getTabById(uid).length>0){
			this.activeTab(uid,nottrigger);
			return;
		}
		this.getActiveTab().removeClass("wbim_active");
		 this.addTab(f);
		 this.onActiveTabChange(nottrigger);
	},
	chatToGroup : function(groupId,nottrigger){
		$(".wbim_chat_ef").fadeIn();
		$(".wbim_chat_box").css("width","520px");
		$(".wbim_chat_box").fadeIn();
		var f = this.getGroup(groupId);
		if(this.getTabById(groupId).length>0){
			this.activeTab(groupId,nottrigger);
			return;
		}
		//显示组成员
		//this.renderGroupMember(groupId);
		this.fetchGroupUserList(groupId);
		
		this.getActiveTab().removeClass("wbim_active");
		 this.addTab(f,"wbim_active","group");
		 this.onActiveTabChange(nottrigger);
	},
	addTab:function(f,cn,type){
		if(!cn){
			cn="wbim_active";
		}
		var li = "";
		if(type){
			li += '<li onclick="IM.chatToGroup('+f.gid+')" type="group" title="' + f.name + '" uid=' + f.gid
			+ ' class="'+cn+'"><div class="wbim_userhead">';
			li += '<img src="'+this.imgbase +"s_"+ f.img + '">';
			li += '<span   class="'+this.getStatusCssName(f.gid)+'"></span>';
			li += '</div><div class="wbim_username"  >' + f.name + '</div>';
			li += '<a hidefocus="true"  node-type="wbim_icon_close_s"  class="wbim_icon_close_s"></a></li>';
			this.chatList.append(li);
			 $("li:[uid="+f.gid+"] a.wbim_icon_close_s").click(function(event){
				 event.stopPropagation();
				 IM.closeChat(f.gid);
			 });
		}else{
			li += '<li onclick="IM.chatTo('+f.id+')" type="single" title="' + f.name + '" uid=' + f.id
			+ ' class="'+cn+'"><div class="wbim_userhead">';

			li += '<img src="'+this.imgbase +"s_"+ f.img + '">';
			li += '<span   class="'+this.getStatusCssName(f.id)+'"></span>';
			li += '</div><div class="wbim_username"  >' + f.name + '</div>';
			li += '<a hidefocus="true"  node-type="wbim_icon_close_s"  class="wbim_icon_close_s"></a></li>';
			this.chatList.append(li);
			 $("li:[uid="+f.id+"] a.wbim_icon_close_s").click(function(event){
				 event.stopPropagation();
				 IM.closeChat(f.id);
			 });
		}
	},
	// 关闭与某人的聊天
	closeChat : function( id) {
		this.getTabById(id).remove();
		if(this.getActiveTab().length==0){
			var first=this.getFirstTab();
			if (first.length > 0) {
				first.addClass("wbim_active");
				this.onActiveTabChange();
			} else {
				this.closeChatWindow();
			}
		}
	},
	// 关闭整个聊天窗口
	closeChatWindow:function(nottrigger){
		$(".wbim_chat_box").fadeOut();
		IM.minBox.attr("class", "wbim_min_box_col2");
		//$(".wbim_chat_box * a.wbim_icon_close").trigger("click");
		this.isChating=false;
		if(nottrigger)
			return;
		this.sendCmd( '{ fun:"IM.closeChatWindow( true)"} ');
	},
	// 最小化聊天窗口
	minChatWindow:function(nottrigger){
		$(".wbim_chat_box").fadeOut();
		//最小化时移除闪烁效果
		IM.minChat.removeClass("wbim_min_chat_msg");
		this.minBox.attr("class", "wbim_min_box_col3");
		this.isChating=false;
		if(nottrigger)
			return;
		this.sendCmd( '{ fun:"IM.minChatWindow( true)"} ');
	},
	maxChatWinow:function(nottrigger){
		$(".wbim_chat_box").fadeIn();
		this.isChating=true;
		if(this.getActiveTab().length==0){
			var first=this.getFirstTab();
			if (first.length > 0) {
				first.addClass("wbim_active");
				this.onActiveTabChange();
			}
		}else{
			var a = this.getActiveTab();
			if (a.length != 0) {
				var uid = a.attr("uid");//type="group"时uid为群组id,type="single"时uid为用户id
				var _type = a.attr("type");
		        if(uid){
					var name = '';
					if(_type == "group"){
						name = this.getGroup(uid).name; // 获取聊天群名称
					}else if(_type == "single"){
						name = this.getUser(uid).name; // 获取好友用户名
					}
					
					$(".wbim_min_nick ").text("正与 "+name+" 聊天中");// 正在与谁聊天的文字显示成当前的
		        }
			}
		}
		if(nottrigger)
			return;
		this.sendCmd( '{ fun:"IM.maxChatWinow( true)"} ');
	},
	maxListWinow:function(nottrigger){
		$(".wbim_list_expand").slideDown();
		if(nottrigger)
			return;
		this.sendCmd( '{ fun:"IM.maxListWinow( true)"} ');
	},
	minListWinow:function(nottrigger){
		$(".wbim_list_expand").slideUp();
		if(nottrigger)
			return;
		this.sendCmd( '{ fun:"IM.minListWinow( true)"} ');
	},
	 
	 
	showOffLineTips:function(){
		$(".wbim_chat_tips").fadeIn();
		$(".wbim_chat_list").attr("style","height: 198px; top: 24px;");
	},
	hiddeOffLineTips:function(){
		$(".wbim_chat_tips").fadeOut();
		$(".wbim_chat_list").attr("style","height: 222px; ");
	},
	initFace:function(){
		var s=[];s[0]="[织]";s[1]="[神马]";s[2]="[浮云]";s[3]="[给力]";s[4]="[围观]";s[5]="[威武]";s[6]="[熊猫]";s[7]="[兔子]";s[8]="[奥特曼]";s[9]="[囧]";s[10]="[互粉]";s[11]="[礼物]";s[12]="[呵呵]";s[13]="[嘻嘻]";s[14]="[哈哈]";s[15]="[可爱]";s[16]="[可怜]";s[17]="[挖鼻屎]";s[18]="[吃惊]";s[19]="[害羞]";s[20]="[挤眼]";s[21]="[闭嘴]";s[22]="[鄙视]";s[23]="[爱你]";s[24]="[泪]";s[25]="[偷笑]";s[26]="[亲亲]";s[27]="[生病]";s[28]="[太开心]";s[29]="[懒得理你]";s[30]="[右哼哼]";s[31]="[左哼哼]";s[32]="[嘘]";s[33]="[衰]";s[34]="[委屈]";s[35]="[吐]";s[36]="[打哈气]";s[37]="[抱抱]";s[38]="[怒]";s[39]="[疑问]";s[40]="[馋嘴]";s[41]="[拜拜]";s[42]="[思考]";s[43]="[汗]";s[44]="[困]";s[45]="[睡觉]";s[46]="[钱]";s[47]="[失望]";s[48]="[酷]";s[49]="[花心]";s[50]="[哼]";s[51]="[鼓掌]";s[52]="[晕]";s[53]="[悲伤]";s[54]="[抓狂]";s[55]="[黑线]";s[56]="[阴险]";s[57]="[怒骂]";s[58]="[心]";s[59]="[伤心]";s[60]="[猪头]";s[61]="[ok]";s[62]="[耶]";s[63]="[good]";s[64]="[不要]";s[65]="[赞]";s[66]="[来]";s[67]="[弱]";s[68]="[蜡烛]";s[69]="[钟]";s[70]="[蛋糕]";s[71]="[话筒]";
		
		for(var i=0;i<s.length;i++ ){
			this.faceHash[s[i]]=i+".gif";
		}
		this.faceHash.src=s;
        this.emojiHash["[em电话听筒]"]="1f4de.png";this.emojiHash["[em公羊]"]="1f40f.png";this.emojiHash["[em看不到邪恶]"]="1f648.png";this.emojiHash["[em钱包]"]="1f45b.png";this.emojiHash["[em_ng]"]="1f196.png";this.emojiHash["[em太阳眼镜]"]="1f60e.png";this.emojiHash["[em左边]"]="1f448.png";this.emojiHash["[em鸡]"]="1f414.png";this.emojiHash["[em凯旋]"]="1f624.png";this.emojiHash["[em樱桃]"]="1f352.png";this.emojiHash["[em数字10]"]="1f51f.png";this.emojiHash["[em有]"]="1f236.png";this.emojiHash["[em狗]"]="1f415.png";this.emojiHash["[em办公楼]"]="1f3e2.png";this.emojiHash["[em葡萄酒酒杯]"]="1f377.png";this.emojiHash["[em闪电]"]="26a1.png";this.emojiHash["[em赛车终点]"]="1f3c1.png";this.emojiHash["[em大蓝钻]"]="1f537.png";this.emojiHash["[em能]"]="1f43b.png";this.emojiHash["[em月]"]="1f237.png";this.emojiHash["[em鬼脸2]"]="1f62c.png";this.emojiHash["[em日本剪影]"]="1f5fe.png";this.emojiHash["[em新月脸]"]="1f31a.png";this.emojiHash["[em丝带心]"]="1f49d.png";this.emojiHash["[em家庭]"]="1f46a.png";this.emojiHash["[em日本国旗]"]="1f1ef-1f1f5.png";this.emojiHash["[抓狂]"]="54.gif";this.emojiHash["[em好]"]="1f44c.png";this.emojiHash["[em火箭]"]="1f680.png";this.emojiHash["[em钱袋]"]="1f4b0.png";this.emojiHash["[em无辜]"]="1f607.png";this.emojiHash["[em顶]"]="1f199.png";this.emojiHash["[em跑步]"]="1f3c3.png";this.emojiHash["[em笑眼猫]"]="1f638.png";this.emojiHash["[em蘑菇]"]="1f344.png";this.emojiHash["[em索道]"]="1f6a0.png";this.emojiHash["[em米饼]"]="1f358.png";this.emojiHash["[em碰撞]"]="1f4a5.png";this.emojiHash["[em调色板]"]="1f3a8.png";this.emojiHash["[弱]"]="67.gif";this.emojiHash["[em掌印]"]="1f43e.png";this.emojiHash["[em减]"]="2796.png";this.emojiHash["[em烟火1]"]="1f386.png";this.emojiHash["[em握拳]"]="270a.png";this.emojiHash["[em熊猫]"]="1f43c.png";this.emojiHash["[em丝带]"]="1f380.png";this.emojiHash["[em洗澡]"]="1f6c0.png";this.emojiHash["[em红绿灯]"]="1f6a5.png";this.emojiHash["[em望远镜]"]="1f52d.png";this.emojiHash["[em稻穗]"]="1f33e.png";this.emojiHash["[em_triangular_flag_on_post]"]="1f6a9.png";this.emojiHash["[em2点]"]="1f551.png";this.emojiHash["[em鸟]"]="1f426.png";this.emojiHash["[em幽灵鬼脸]"]="1f47b.png";this.emojiHash["[黑线]"]="55.gif";this.emojiHash["[em雨伞]"]="1f302.png";this.emojiHash["[em兔子]"]="1f430.png";this.emojiHash["[em锁墨水笔]"]="1f50f.png";this.emojiHash["[em柑橘]"]="1f34a.png";this.emojiHash["[em音符]"]="1f3b5.png";this.emojiHash["[em_accept]"]="1f251.png";this.emojiHash["[em旋转心]"]="1f49e.png";this.emojiHash["[酷]"]="48.gif";this.emojiHash["[em糟糕]"]="1f630.png";this.emojiHash["[em一见钟情]"]="1f498.png";this.emojiHash["[em婴儿]"]="1f476.png";this.emojiHash["[em爱心]"]="1f497.png";this.emojiHash["[em嘴巴]"]="1f444.png";this.emojiHash["[em裙子]"]="1f457.png";this.emojiHash["[em打折割]"]="1f239.png";this.emojiHash["[em蚂蚁]"]="1f41c.png";this.emojiHash["[em八辐条星号]"]="2733.png";this.emojiHash["[em上面]"]="1f446.png";this.emojiHash["[em向上红三角]"]="1f53a.png";this.emojiHash["[em快乐猫]"]="1f639.png";this.emojiHash["[em足球]"]="26bd.png";this.emojiHash["[em鲤鱼幡]"]="1f38f.png";this.emojiHash["[em树袋熊]"]="1f428.png";this.emojiHash["[em收音机]"]="1f4fb.png";this.emojiHash["[em烟火2]"]="1f387.png";this.emojiHash["[em上箭头]"]="2b06.png";this.emojiHash["[围观]"]="4.gif";this.emojiHash["[em11点]"]="1f55a.png";this.emojiHash["[em蛇]"]="1f40d.png";this.emojiHash["[可爱]"]="15.gif";this.emojiHash["[em沙漏与流砂]"]="23f3.png";this.emojiHash["[em啦啦队]"]="1f4e3.png";this.emojiHash["[em铃铛]"]="1f514.png";this.emojiHash["[em吸烟]"]="1f6ac.png";this.emojiHash["[em礼物]"]="1f381.png";this.emojiHash["[em特价]"]="1f250.png";this.emojiHash["[em叶子]"]="1f343.png";this.emojiHash["[x不要]"]="x1.gif";this.emojiHash["[em11点半]"]="1f566.png";this.emojiHash["[em加油]"]="26fd.png";this.emojiHash["[奥特曼]"]="8.gif";this.emojiHash["[em架空索道]"]="1f6a1.png";this.emojiHash["[em老虎2]"]="1f405.png";this.emojiHash["[互粉]"]="10.gif";this.emojiHash["[左哼哼]"]="31.gif";this.emojiHash["[em左下箭头]"]="2199.png";this.emojiHash["[em大蓝圈]"]="1f535.png";this.emojiHash["[em仓鼠]"]="1f439.png";this.emojiHash["[em_put_litter_in_its_place]"]="1f6ae.png";this.emojiHash["[em拖拉机]"]="1f69c.png";this.emojiHash["[em卫星天线]"]="1f4e1.png";this.emojiHash["[em右下箭头]"]="2198.png";this.emojiHash["[em手掌]"]="270b.png";this.emojiHash["[em咖啡]"]="2615.png";this.emojiHash["[em向日葵]"]="1f33b.png";this.emojiHash["[em不屈不挠]"]="1f623.png";this.emojiHash["[em厌倦]"]="1f629.png";this.emojiHash["[em学校]"]="1f3eb.png";this.emojiHash["[em热带饮料]"]="1f379.png";this.emojiHash["[x兴奋]"]="x15.gif";this.emojiHash["[em回形针]"]="1f4ce.png";this.emojiHash["[em379]"]="1f532.png";this.emojiHash["[em皱眉头]"]="1f626.png";this.emojiHash["[em花束]"]="1f490.png";this.emojiHash["[em舌头]"]="1f445.png";this.emojiHash["[em饮用水符号]"]="1f6b0.png";this.emojiHash["[em_hocho]"]="1f52a.png";this.emojiHash["[em开口]"]="1f62e.png";this.emojiHash["[em篮球]"]="1f3c0.png";this.emojiHash["[em吉它]"]="1f3b8.png";this.emojiHash["[em茶杯]"]="1f375.png";this.emojiHash["[em向下红三角]"]="1f53b.png";this.emojiHash["[挖鼻屎]"]="17.gif";this.emojiHash["[em河豚]"]="1f421.png";this.emojiHash["[em滴]"]="1f4a7.png";this.emojiHash["[em1234]"]="1f522.png";this.emojiHash["[不要]"]="64.gif";this.emojiHash["[em巨蟹座]"]="264b.png";this.emojiHash["[em_mailbox_with_mail]"]="1f4ec.png";this.emojiHash["[em显微镜]"]="1f52c.png";this.emojiHash["[em仙人掌]"]="1f335.png";this.emojiHash["[em真棒]"]="1f44d.png";this.emojiHash["[em渐盈凸月]"]="1f314.png";this.emojiHash["[思考]"]="42.gif";this.emojiHash["[em闭合锁的钥匙]"]="1f510.png";this.emojiHash["[em上弦月]"]="1f313.png";this.emojiHash["[em马]"]="1f40e.png";this.emojiHash["[em下弦月脸]"]="1f31c.png";this.emojiHash["[em标志P]"]="1f17f.png";this.emojiHash["[em寂静]"]="1f62f.png";this.emojiHash["[em保龄球]"]="1f3b3.png";this.emojiHash["[em温泉]"]="2668.png";this.emojiHash["[em链接]"]="1f517.png";this.emojiHash["[em电车]"]="1f683.png";this.emojiHash["[em电灯泡]"]="1f4a1.png";this.emojiHash["[em小猴子]"]="1f412.png";this.emojiHash["[em假笑]"]="1f60f.png";this.emojiHash["[em金发碧眼]"]="1f471.png";this.emojiHash["[em小蓝钻]"]="1f539.png";this.emojiHash["[em警察]"]="1f46e.png";this.emojiHash["[em刀叉]"]="1f374.png";this.emojiHash["[囧]"]="9.gif";this.emojiHash["[em禁音]"]="1f507.png";this.emojiHash["[em雪花]"]="2744.png";this.emojiHash["[em营业]"]="1f23a.png";this.emojiHash["[emo失望]"]="1f61e.png";this.emojiHash["[太开心]"]="28.gif";this.emojiHash["[em电话]"]="260e.png";this.emojiHash["[em大象]"]="1f418.png";this.emojiHash["[em空]"]="1f233.png";this.emojiHash["[失望]"]="47.gif";this.emojiHash["[em飞吻]"]="1f618.png";this.emojiHash["[em页的卷曲]"]="1f4c3.png";this.emojiHash["[心]"]="58.gif";this.emojiHash["[em郁金香]"]="1f337.png";this.emojiHash["[em饼干]"]="1f36a.png";this.emojiHash["[em双鱼座]"]="2653.png";this.emojiHash["[em龙卷风]"]="1f300.png";this.emojiHash["[em音箱]"]="1f508.png";this.emojiHash["[em美国国旗]"]="1f1fa-1f1f8.png";this.emojiHash["[em记录]"]="1f4dd.png";this.emojiHash["[em迎面bus]"]="1f68d.png";this.emojiHash["[em剪刀]"]="2702.png";this.emojiHash["[em日元]"]="1f4b4.png";this.emojiHash["[em山地自行车骑士]"]="1f6b5.png";this.emojiHash["[em4点]"]="1f553.png";this.emojiHash["[em黄昏]"]="1f306.png";this.emojiHash["[em_arrow_heading_up]"]="2934.png";this.emojiHash["[em8点半]"]="1f563.png";this.emojiHash["[em单峰驼驼]"]="1f42a.png";this.emojiHash["[em白中星]"]="2b50.png";this.emojiHash["[em书本]"]="1f4d6.png";this.emojiHash["[em符号7]"]="2734.png";this.emojiHash["[睡觉]"]="45.gif";this.emojiHash["[em鼻子]"]="1f443.png";this.emojiHash["[em禁止进入]"]="26d4.png";this.emojiHash["[em禁止骑自行车]"]="1f6b3.png";this.emojiHash["[em右上箭头]"]="2197.png";this.emojiHash["[em家禽LEG]"]="1f357.png";this.emojiHash["[em麦克风]"]="1f3a4.png";this.emojiHash["[em百货商店]"]="1f3ec.png";this.emojiHash["[em风铃]"]="1f390.png";this.emojiHash["[em梨]"]="1f350.png";this.emojiHash["[em禁止进入2]"]="1f6ab.png";this.emojiHash["[em_check]"]="2611.png";this.emojiHash["[em卫兵]"]="1f482.png";this.emojiHash["[em祝]"]="3297.png";this.emojiHash["[em挥手]"]="1f44b.png";this.emojiHash["[蛋糕]"]="70.gif";this.emojiHash["[em不乱丢垃圾]"]="1f6af.png";this.emojiHash["[em声音]"]="1f50a.png";this.emojiHash["[em瓜皮帽]"]="1f472.png";this.emojiHash["[em色]"]="1f60d.png";this.emojiHash["[em啤酒]"]="1f37a.png";this.emojiHash["[em冷汗]"]="1f613.png";this.emojiHash["[em肉类骨]"]="1f356.png";this.emojiHash["[em黑色NIB]"]="2712.png";this.emojiHash["[em淋浴]"]="1f6bf.png";this.emojiHash["[em中国国旗]"]="1f1e8-1f1f3.png";this.emojiHash["[em垂直交通灯]"]="1f6a6.png";this.emojiHash["[疑问]"]="39.gif";this.emojiHash["[em标志O]"]="1f17e.png";this.emojiHash["[em金牛座]"]="2649.png";this.emojiHash["[em迎面的士]"]="1f696.png";this.emojiHash["[em银行]"]="1f3e6.png";this.emojiHash["[em方形十字标记]"]="274e.png";this.emojiHash["[em8点]"]="1f557.png";this.emojiHash["[耶]"]="62.gif";this.emojiHash["[em快进]"]="23e9.png";this.emojiHash["[em打电话]"]="1f4f2.png";this.emojiHash["[em标志AB]"]="1f18e.png";this.emojiHash["[em药丸]"]="1f48a.png";this.emojiHash["[em问号]"]="2754.png";this.emojiHash["[em小橙钻]"]="1f538.png";this.emojiHash["[em龙]"]="1f409.png";this.emojiHash["[em_capital_abcd]"]="1f520.png";this.emojiHash["[嘘]"]="32.gif";this.emojiHash["[em理发店]"]="1f488.png";this.emojiHash["[em5点]"]="1f554.png";this.emojiHash["[emDVD]"]="1f4c0.png";this.emojiHash["[em货车]"]="1f69a.png";this.emojiHash["[em船]"]="1f6a2.png";this.emojiHash["[em上弦月脸]"]="1f31b.png";this.emojiHash["[em咖喱饭]"]="1f35b.png";this.emojiHash["[em火花]"]="2728.png";this.emojiHash["[em长靴]"]="1f462.png";this.emojiHash["[em7点]"]="1f556.png";this.emojiHash["[em鄙视]"]="1f44e.png";this.emojiHash["[em双手合十]"]="1f64f.png";this.emojiHash["[em乐谱]"]="1f3bc.png";this.emojiHash["[em猪鼻子]"]="1f43d.png";this.emojiHash["[em_mailbox_with_no_mail]"]="1f4ed.png";this.emojiHash["[em摩蝎座]"]="2651.png";this.emojiHash["[em儿童过境]"]="1f6b8.png";this.emojiHash["[em打x]"]="274c.png";this.emojiHash["[em外星人]"]="1f47d.png";this.emojiHash["[em符号C]"]="00a9.png";this.emojiHash["[em下弦月]"]="1f317.png";this.emojiHash["[x吐舌]"]="x14.gif";this.emojiHash["[em剪贴板]"]="1f4cb.png";this.emojiHash["[em毕业帽]"]="1f393.png";this.emojiHash["[em表演艺术]"]="1f3ad.png";this.emojiHash["[em磁悬浮列车]"]="1f69f.png";this.emojiHash["[em天使]"]="1f47c.png";this.emojiHash["[em绿心]"]="1f49a.png";this.emojiHash["[em白框]"]="25fb.png";this.emojiHash["[晕]"]="52.gif";this.emojiHash["[em薯条]"]="1f35f.png";this.emojiHash["[em汗微笑]"]="1f605.png";this.emojiHash["[em蒸汽机车]"]="1f682.png";this.emojiHash["[em白色大框]"]="2b1c.png";this.emojiHash["[em满月脸]"]="1f31d.png";this.emojiHash["[em担忧]"]="1f61f.png";this.emojiHash["[em对比]"]="1f19a.png";this.emojiHash["[em小狗]"]="1f436.png";this.emojiHash["[em气球]"]="1f388.png";this.emojiHash["[em关东煮]"]="1f362.png";this.emojiHash["[em海豚]"]="1f42c.png";this.emojiHash["[em信箱]"]="1f4eb.png";this.emojiHash["[em取款机]"]="1f3e7.png";this.emojiHash["[em4点半]"]="1f55f.png";this.emojiHash["[em救护车]"]="1f691.png";this.emojiHash["[em冰淇淋]"]="1f366.png";this.emojiHash["[em包裹]"]="1f4e6.png";this.emojiHash["[em西瓜]"]="1f349.png";this.emojiHash["[em骆驼]"]="1f42b.png";this.emojiHash["[em橙书]"]="1f4d9.png";this.emojiHash["[em扳手]"]="1f527.png";this.emojiHash["[em樱花]"]="1f338.png";this.emojiHash["[em100]"]="1f4af.png";this.emojiHash["[em厕所]"]="1f6bd.png";this.emojiHash["[em相机]"]="1f4f7.png";this.emojiHash["[em帆船]"]="26f5.png";this.emojiHash["[em野猪]"]="1f417.png";this.emojiHash["[em出租车]"]="1f695.png";this.emojiHash["[em大便]"]="1f4a9.png";this.emojiHash["[em射手座]"]="2650.png";this.emojiHash["[em波浪]"]="1f30a.png";this.emojiHash["[em哈哈]"]="1f604.png";this.emojiHash["[em龟]"]="1f422.png";this.emojiHash["[可怜]"]="16.gif";this.emojiHash["[em酒杯]"]="1f378.png";this.emojiHash["[em法国国旗]"]="1f1eb-1f1f7.png";this.emojiHash["[em猴脸]"]="1f435.png";this.emojiHash["[em单音箱]"]="1f509.png";this.emojiHash["[em发邮件]"]="1f4e9.png";this.emojiHash["[em蓝心]"]="1f499.png";this.emojiHash["[em汤面]"]="1f35c.png";this.emojiHash["[em_repeat_one]"]="1f502.png";this.emojiHash["[em黑色问号]"]="2753.png";this.emojiHash["[em桃心信封]"]="1f48c.png";this.emojiHash["[em棒球]"]="26be.png";this.emojiHash["[鄙视]"]="22.gif";this.emojiHash["[em上升图表]"]="1f4b9.png";this.emojiHash["[em猪]"]="1f416.png";this.emojiHash["[em摄相机]"]="1f3a5.png";this.emojiHash["[em烹饪]"]="1f373.png";this.emojiHash["[em网球]"]="1f3be.png";this.emojiHash["[em老鼠]"]="1f42d.png";this.emojiHash["[good]"]="63.gif";this.emojiHash["[em单选按钮]"]="1f518.png";this.emojiHash["[em企鹅]"]="1f427.png";this.emojiHash["[em处女座]"]="264d.png";this.emojiHash["[em害怕]"]="1f628.png";this.emojiHash["[em男鞋]"]="1f45e.png";this.emojiHash["[em上升趋势图表]"]="1f4c8.png";this.emojiHash["[em礼帽]"]="1f3a9.png";this.emojiHash["[阴险]"]="56.gif";this.emojiHash["[em鼓掌]"]="1f44f.png";this.emojiHash["[em_articulated_lorry]"]="1f69b.png";this.emojiHash["[emTABS书签]"]="1f4d1.png";this.emojiHash["[em7点半]"]="1f562.png";this.emojiHash["[em骷髅头]"]="1f480.png";this.emojiHash["[em邮箱关闭]"]="1f4ea.png";this.emojiHash["[em迎面汽车]"]="1f698.png";this.emojiHash["[em_customs]"]="1f6c3.png";this.emojiHash["[蜡烛]"]="68.gif";this.emojiHash["[em落叶树]"]="1f333.png";this.emojiHash["[em害羞]"]="1f633.png";this.emojiHash["[em中性face]"]="1f610.png";this.emojiHash["[em指甲油]"]="1f485.png";this.emojiHash["[em豹]"]="1f406.png";this.emojiHash["[em婚礼]"]="1f492.png";this.emojiHash["[em警车转灯]"]="1f6a8.png";this.emojiHash["[em_dot_diamond_shape]"]="1f4a0.png";this.emojiHash["[em录像带]"]="1f4fc.png";this.emojiHash["[x好冷]"]="x7.gif";this.emojiHash["[em紫心]"]="1f49c.png";this.emojiHash["[em太阳脸]"]="1f31e.png";this.emojiHash["[em苦涩]"]="1f627.png";this.emojiHash["[em_打勾]"]="2705.png";this.emojiHash["[em女人]"]="1f469.png";this.emojiHash["[em重感叹号]"]="2757.png";this.emojiHash["[em比基尼]"]="1f459.png";this.emojiHash["[悲伤]"]="53.gif";this.emojiHash["[em婴儿符号]"]="1f6bc.png";this.emojiHash["[em卷轴]"]="1f4dc.png";this.emojiHash["[em单轨]"]="1f69d.png";this.emojiHash["[em_black_universal]"]="267b.png";this.emojiHash["[em生病]"]="1f637.png";this.emojiHash["[em枫叶]"]="1f341.png";this.emojiHash["[em赛马]"]="1f3c7.png";this.emojiHash["[em水瓶座]"]="2652.png";this.emojiHash["[em食指]"]="261d.png";this.emojiHash["[em睡觉]"]="1f4a4.png";this.emojiHash["[em牵手的男人]"]="1f46c.png";this.emojiHash["[em除]"]="2797.png";this.emojiHash["[em手枪]"]="1f52b.png";this.emojiHash["[em公鸡]"]="1f413.png";this.emojiHash["[em比萨饼]"]="1f355.png";this.emojiHash["[em情侣夫妇]"]="1f491.png";this.emojiHash["[em寿司]"]="1f363.png";this.emojiHash["[em残月]"]="1f318.png";this.emojiHash["[em座位]"]="1f4ba.png";this.emojiHash["[em开口笑]"]="1f603.png";this.emojiHash["[emWC厕所]"]="1f6be.png";this.emojiHash["[em意大利国旗]"]="1f1ee-1f1f9.png";this.emojiHash["[em标志A]"]="1f170.png";this.emojiHash["[em理发]"]="1f487.png";this.emojiHash["[em高尔夫]"]="26f3.png";this.emojiHash["[亲亲]"]="26.gif";this.emojiHash["[em和服]"]="1f458.png";this.emojiHash["[em_e-mail]"]="1f4e7.png";this.emojiHash["[em_SPARKLE]"]="2747.png";this.emojiHash["[em邮局]"]="1f3e3.png";this.emojiHash["[em鄙视~不高兴]"]="1f612.png";this.emojiHash["[em鼠]"]="1f401.png";this.emojiHash["[em夕阳]"]="1f307.png";this.emojiHash["[em六角座]"]="1f52f.png";this.emojiHash["[em母牛]"]="1f42e.png";this.emojiHash["[em迷你光盘]"]="1f4bd.png";this.emojiHash["[em撅嘴猫]"]="1f63e.png";this.emojiHash["[em小巴]"]="1f690.png";this.emojiHash["[em标志B]"]="1f171.png";this.emojiHash["[em喜欢2]"]="1f493.png";this.emojiHash["[em卫生间]"]="1f6bb.png";this.emojiHash["[织]"]="0.gif";this.emojiHash["[em火车]"]="1f685.png";this.emojiHash["[em迷茫]"]="1f615.png";this.emojiHash["[em_白色花]"]="1f4ae.png";this.emojiHash["[x点头]"]="x4.gif";this.emojiHash["[em打开文件夹]"]="1f4c2.png";this.emojiHash["[em加]"]="2795.png";this.emojiHash["[em_arrow_down_small]"]="1f53d.png";this.emojiHash["[em_game_die]"]="1f3b2.png";this.emojiHash["[em震动模式]"]="1f4f3.png";this.emojiHash["[em_hatching_chick]"]="1f423.png";this.emojiHash["[em酷]"]="1f192.png";this.emojiHash["[em黑小框1]"]="25aa.png";this.emojiHash["[em电影放映机]"]="1f3a6.png";this.emojiHash["[em小鸡]"]="1f424.png";this.emojiHash["[em香蕉]"]="1f34c.png";this.emojiHash["[em日出1]"]="1f304.png";this.emojiHash["[em休闲车]"]="1f699.png";this.emojiHash["[em新月]"]="1f311.png";this.emojiHash["[em高兴]"]="1f60a.png";this.emojiHash["[em左右箭头]"]="2194.png";this.emojiHash["[em女式帽]"]="1f452.png";this.emojiHash["[em蓝书]"]="1f4d8.png";this.emojiHash["[em和服娃娃]"]="1f38e.png";this.emojiHash["[em马头]"]="1f434.png";this.emojiHash["[em_free]"]="1f193.png";this.emojiHash["[em日出2]"]="1f305.png";this.emojiHash["[em酒店]"]="1f3e8.png";this.emojiHash["[em列车]"]="1f686.png";this.emojiHash["[em梅花]"]="2663.png";this.emojiHash["[em下降趋势图表]"]="1f4c9.png";this.emojiHash["[em光学光盘]"]="1f4bf.png";this.emojiHash["[泪]"]="24.gif";this.emojiHash["[熊猫]"]="6.gif";this.emojiHash["[em_abcd]"]="1f521.png";this.emojiHash["[挤眼]"]="20.gif";this.emojiHash["[em水牛]"]="1f403.png";this.emojiHash["[em圣诞树]"]="1f384.png";this.emojiHash["[em非饮用水]"]="1f6b1.png";this.emojiHash["[em视频游戏]"]="1f3ae.png";this.emojiHash["[em行人]"]="1f6b6.png";this.emojiHash["[嘻嘻]"]="13.gif";this.emojiHash["[em公共洗车]"]="1f68c.png";this.emojiHash["[em不能使用电话]"]="1f4f5.png";this.emojiHash["[em快跑]"]="1f4a8.png";this.emojiHash["[em赏月仪式]"]="1f391.png";this.emojiHash["[em按摩]"]="1f486.png";this.emojiHash["[em柠檬]"]="1f34b.png";this.emojiHash["[em快退]"]="23ea.png";this.emojiHash["[em脚印]"]="1f463.png";this.emojiHash["[em页面朝上]"]="1f4c4.png";this.emojiHash["[em盒饭]"]="1f371.png";this.emojiHash["[em闭眼接吻猫]"]="1f63d.png";this.emojiHash["[em楼房建筑]"]="1f3e0.png";this.emojiHash["[em黑色大框]"]="2b1b.png";this.emojiHash["[em双子座]"]="264a.png";this.emojiHash["[em沙漏]"]="231b.png";this.emojiHash["[em吃惊]"]="1f632.png";this.emojiHash["[em棕榈树]"]="1f334.png";this.emojiHash["[em书签]"]="1f516.png";this.emojiHash["[em骑自行车]"]="1f6b4.png";this.emojiHash["[em葡萄]"]="1f347.png";this.emojiHash["[em3点半]"]="1f55e.png";this.emojiHash["[em日本城堡]"]="1f3ef.png";this.emojiHash["[em俄罗斯国旗]"]="1f1f7-1f1fa.png";this.emojiHash["[em直升机]"]="1f681.png";this.emojiHash["[em落叶]"]="1f342.png";this.emojiHash["[em银河系]"]="1f30c.png";this.emojiHash["[em秘密]"]="3299.png";this.emojiHash["[em眩目]"]="1f4ab.png";this.emojiHash["[em下面]"]="1f447.png";this.emojiHash["[话筒]"]="71.gif";this.emojiHash["[吃惊]"]="18.gif";this.emojiHash["[em白小框]"]="25fd.png";this.emojiHash["[em噘嘴]"]="1f64e.png";this.emojiHash["[em左箭头]"]="2b05.png";this.emojiHash["[em桃子]"]="1f351.png";this.emojiHash["[em音乐键盘]"]="1f3b9.png";this.emojiHash["[em合上的书]"]="1f4d5.png";this.emojiHash["[em_moyai]"]="1f5ff.png";this.emojiHash["[鼓掌]"]="51.gif";this.emojiHash["[em沉思]"]="1f60c.png";this.emojiHash["[em欧元]"]="1f4b6.png";this.emojiHash["[em欧洲邮局]"]="1f3e4.png";this.emojiHash["[em大哭]"]="1f62d.png";this.emojiHash["[em闭眼]"]="1f61d.png";this.emojiHash["[em手表]"]="231a.png";this.emojiHash["[em高跟鞋]"]="1f460.png";this.emojiHash["[em假名SA]"]="1f202.png";this.emojiHash["[em_card_index]"]="1f4c7.png";this.emojiHash["[em胜利]"]="270c.png";this.emojiHash["[em轻轨]"]="1f688.png";this.emojiHash["[em蜗牛]"]="1f40c.png";this.emojiHash["[em381]"]="1f533.png";this.emojiHash["[em品尝美味]"]="1f60b.png";this.emojiHash["[em派对]"]="1f389.png";this.emojiHash["[em皇冠]"]="1f451.png";this.emojiHash["[em蛋羹]"]="1f36e.png";this.emojiHash["[em左上箭头]"]="2196.png";this.emojiHash["[em多本书]"]="1f4da.png";this.emojiHash["[em眼睛]"]="1f440.png";this.emojiHash["[em笔记本]"]="1f4d3.png";this.emojiHash["[em东京塔]"]="1f5fc.png";this.emojiHash["[em娥眉月]"]="1f312.png";this.emojiHash["[em茄子]"]="1f346.png";this.emojiHash["[em小提琴]"]="1f3bb.png";this.emojiHash["[em青苹果]"]="1f34f.png";this.emojiHash["[吐]"]="35.gif";this.emojiHash["[em橄榄球]"]="1f3c8.png";this.emojiHash["[em带花园的房子]"]="1f3e1.png";this.emojiHash["[em380]"]="1f534.png";this.emojiHash["[em蛇夫座]"]="26ce.png";this.emojiHash["[em合]"]="1f234.png";this.emojiHash["[em服务员]"]="1f481.png";this.emojiHash["[em韩国国旗]"]="1f1f0-1f1f7.png";this.emojiHash["[em日文OGRE]"]="1f479.png";this.emojiHash["[em书包]"]="1f392.png";this.emojiHash["[em_passport_control]"]="1f6c2.png";this.emojiHash["[em打伞]"]="2614.png";this.emojiHash["[em旋转木马]"]="1f3a0.png";this.emojiHash["[em_arrow_heading_down]"]="2935.png";this.emojiHash["[em向右箭头钩]"]="21aa.png";this.emojiHash["[em不高兴]"]="1f620.png";this.emojiHash["[em鲸鱼]"]="1f433.png";this.emojiHash["[em龙脸]"]="1f432.png";this.emojiHash["[花心]"]="49.gif";this.emojiHash["[em猫]"]="1f431.png";this.emojiHash["[em_M]"]="24c2.png";this.emojiHash["[衰]"]="33.gif";this.emojiHash["[em大橙钻]"]="1f536.png";this.emojiHash["[x惊讶]"]="x9.gif";this.emojiHash["[em蜜罐]"]="1f36f.png";this.emojiHash["[em禁止吸烟]"]="1f6ad.png";this.emojiHash["[em图钉]"]="1f4cc.png";this.emojiHash["[em迎面警车]"]="1f694.png";this.emojiHash["[猪头]"]="60.gif";this.emojiHash["[em晕]"]="1f635.png";this.emojiHash["[em女厕]"]="1f6ba.png";this.emojiHash["[em身份ID]"]="1f194.png";this.emojiHash["[神马]"]="1.gif";this.emojiHash["[em贝壳]"]="1f41a.png";this.emojiHash["[em双手抱头]"]="1f646.png";this.emojiHash["[抱抱]"]="37.gif";this.emojiHash["[em日文goblin]"]="1f47a.png";this.emojiHash["[em山区铁路]"]="1f69e.png";this.emojiHash["[em10点]"]="1f559.png";this.emojiHash["[em传真机]"]="1f4e0.png";this.emojiHash["[em台球]"]="1f3b1.png";this.emojiHash["[伤心]"]="59.gif";this.emojiHash["[礼物]"]="11.gif";this.emojiHash["[em_repeat]"]="1f501.png";this.emojiHash["[em下箭头]"]="2b07.png";this.emojiHash["[em自由女神]"]="1f5fd.png";this.emojiHash["[em重美元标志]"]="1f4b2.png";this.emojiHash["[em幼苗]"]="1f331.png";this.emojiHash["[em男人]"]="1f468.png";this.emojiHash["[em撅嘴]"]="1f621.png";this.emojiHash["[em老爷爷]"]="1f474.png";this.emojiHash["[em牛]"]="1f404.png";this.emojiHash["[em公主]"]="1f478.png";this.emojiHash["[em火花心]"]="1f496.png";this.emojiHash["[em雪人]"]="26c4.png";this.emojiHash["[em女孩]"]="1f467.png";this.emojiHash["[em笑眼吻]"]="1f619.png";this.emojiHash["[x哈哈]"]="x5.gif";this.emojiHash["[em电脑]"]="1f4bb.png";this.emojiHash["[x伤心]"]="x12.gif";this.emojiHash["[em_grinning]"]="1f600.png";this.emojiHash["[em鱼竿和鱼]"]="1f3a3.png";this.emojiHash["[em猫2]"]="1f408.png";this.emojiHash["[em红桃]"]="2665.png";this.emojiHash["[em睡觉2]"]="1f634.png";this.emojiHash["[em面包]"]="1f35e.png";this.emojiHash["[em条形图]"]="1f4ca.png";this.emojiHash["[em3点]"]="1f552.png";this.emojiHash["[em手提包]"]="1f45c.png";this.emojiHash["[em1点]"]="1f550.png";this.emojiHash["[em教堂]"]="26ea.png";this.emojiHash["[em_Right]"]="2714.png";this.emojiHash["[em说不出邪恶]"]="1f64a.png";this.emojiHash["[em双心]"]="1f495.png";this.emojiHash["[em信号]"]="1f4f6.png";this.emojiHash["[em双三角DOWN]"]="23ec.png";this.emojiHash["[em无]"]="1f21a.png";this.emojiHash["[em数字6]"]="0036-20e3.png";this.emojiHash["[em清酒]"]="1f376.png";this.emojiHash["[em跑步衫]"]="1f3bd.png";this.emojiHash["[em听不到邪恶]"]="1f649.png";this.emojiHash["[em符号TM]"]="2122.png";this.emojiHash["[em电池]"]="1f50b.png";this.emojiHash["[em陨星]"]="1f320.png";this.emojiHash["[em公牛]"]="1f402.png";this.emojiHash["[em符号R]"]="00ae.png";this.emojiHash["[em天蝎座]"]="264f.png";this.emojiHash["[em歌记号]"]="303d.png";this.emojiHash["[em手影手掌]"]="1f450.png";this.emojiHash["[em工厂]"]="1f3ed.png";this.emojiHash["[em数字7]"]="0037-20e3.png";this.emojiHash["[em便利商店]"]="1f3ea.png";this.emojiHash["[em圆圈]"]="2b55.png";this.emojiHash["[em_outbox_tray]"]="1f4e4.png";this.emojiHash["[em符号]"]="1f530.png";this.emojiHash["[em亚洲地球]"]="1f30f.png";this.emojiHash["[em门]"]="1f6aa.png";this.emojiHash["[em欧洲城堡]"]="1f3f0.png";this.emojiHash["[em冰淇淋2]"]="1f368.png";this.emojiHash["[em双手庆祝]"]="1f64c.png";this.emojiHash["[偷笑]"]="25.gif";this.emojiHash["[em鼠2]"]="1f400.png";this.emojiHash["[em英国国旗]"]="1f1ec-1f1e7.png";this.emojiHash["[em数字4]"]="0034-20e3.png";this.emojiHash["[em炸弹]"]="1f4a3.png";this.emojiHash["[em好运]"]="1f340.png";this.emojiHash["[em心眼笑脸猫]"]="1f63b.png";this.emojiHash["[em右边]"]="1f449.png";this.emojiHash["[em主播]"]="2693.png";this.emojiHash["[em无轨电车]"]="1f68e.png";this.emojiHash["[em鞠躬]"]="1f647.png";this.emojiHash["[em兔]"]="1f407.png";this.emojiHash["[em电车2]"]="1f68a.png";this.emojiHash["[em货币兑换]"]="1f4b1.png";this.emojiHash["[em数字5]"]="0035-20e3.png";this.emojiHash["[em行李认领]"]="1f6c4.png";this.emojiHash["[em老虎]"]="1f42f.png";this.emojiHash["[em报纸]"]="1f4f0.png";this.emojiHash["[em_top]"]="1f51d.png";this.emojiHash["[em兔女郎]"]="1f46f.png";this.emojiHash["[em汽车]"]="1f697.png";this.emojiHash["[em申请]"]="1f238.png";this.emojiHash["[em火车站]"]="1f689.png";this.emojiHash["[em带翅膀的钱]"]="1f4b8.png";this.emojiHash["[em锤子]"]="1f528.png";this.emojiHash["[em多云]"]="2601.png";this.emojiHash["[em瓜]"]="1f348.png";this.emojiHash["[em生日庆祝]"]="1f382.png";this.emojiHash["[em哭泣猫]"]="1f63f.png";this.emojiHash["[em数字2]"]="0032-20e3.png";this.emojiHash["[em12点]"]="1f55b.png";this.emojiHash["[em_twisted_rightwards_arrows]"]="1f500.png";this.emojiHash["[em5点半]"]="1f560.png";this.emojiHash["[em马戏团帐篷]"]="1f3aa.png";this.emojiHash["[em圣诞老人]"]="1f385.png";this.emojiHash["[em邮箱邮筒]"]="1f4ee.png";this.emojiHash["[em心碎]"]="1f494.png";this.emojiHash["[em钻石]"]="1f48e.png";this.emojiHash["[em鬼脸]"]="1f61c.png";this.emojiHash["[em_arrows_counterclockwise]"]="1f504.png";this.emojiHash["[哼]"]="50.gif";this.emojiHash["[em青蛙]"]="1f438.png";this.emojiHash["[右哼哼]"]="30.gif";this.emojiHash["[em袋]"]="1f45d.png";this.emojiHash["[em浴盆]"]="1f6c1.png";this.emojiHash["[em女士衣服]"]="1f45a.png";this.emojiHash["[em亲一口]"]="1f61a.png";this.emojiHash["[em火焰]"]="1f525.png";this.emojiHash["[em渐亏凸月]"]="1f316.png";this.emojiHash["[闭嘴]"]="21.gif";this.emojiHash["[em凉鞋]"]="1f461.png";this.emojiHash["[em黑桃]"]="2660.png";this.emojiHash["[em富士山]"]="1f5fb.png";this.emojiHash["[钱]"]="46.gif";this.emojiHash["[em彩虹]"]="1f308.png";this.emojiHash["[em警告]"]="26a0.png";this.emojiHash["[em喷水池]"]="26f2.png";this.emojiHash["[em草本植物]"]="1f33f.png";this.emojiHash["[em禁]"]="1f232.png";this.emojiHash["[em双手交叉胸前]"]="1f645.png";this.emojiHash["[em数字3]"]="0033-20e3.png";this.emojiHash["[emOK]"]="1f197.png";this.emojiHash["[em美洲地球]"]="1f30e.png";this.emojiHash["[em南瓜灯]"]="1f383.png";this.emojiHash["[em信用卡]"]="1f4b3.png";this.emojiHash["[em深思]"]="1f614.png";this.emojiHash["[em胸牌]"]="1f4db.png";this.emojiHash["[em文件夹]"]="1f4c1.png";this.emojiHash["[em_busts_in_silhouette]"]="1f465.png";this.emojiHash["[爱你]"]="23.gif";this.emojiHash["[em满月]"]="1f315.png";this.emojiHash["[em热带鱼]"]="1f420.png";this.emojiHash["[em鱼]"]="1f41f.png";this.emojiHash["[em男厕]"]="1f6b9.png";this.emojiHash["[x沮丧]"]="x10.gif";this.emojiHash["[em命中]"]="1f3af.png";this.emojiHash["[em_bust_in_silhouette]"]="1f464.png";this.emojiHash["[em中等黑圈]"]="26ab.png";this.emojiHash["[em数字0]"]="0030-20e3.png";this.emojiHash["[em高亮度符号]"]="1f506.png";this.emojiHash["[em笑脸猫]"]="1f63a.png";this.emojiHash["[em红中]"]="1f004.png";this.emojiHash["[em_curly_loop]"]="27b0.png";this.emojiHash["[em1点半]"]="1f55c.png";this.emojiHash["[em三叉戟]"]="1f531.png";this.emojiHash["[em信源]"]="2139.png";this.emojiHash["[em数字1]"]="0031-20e3.png";this.emojiHash["[来]"]="66.gif";this.emojiHash["[em9点]"]="1f558.png";this.emojiHash["[em向左箭头钩]"]="21a9.png";this.emojiHash["[em鲸]"]="1f40b.png";this.emojiHash["[em_cl]"]="1f191.png";this.emojiHash["[em心]"]="2764.png";this.emojiHash["[em9点半]"]="1f564.png";this.emojiHash["[em指向右边的放大镜]"]="1f50e.png";this.emojiHash["[em_end]"]="1f51a.png";this.emojiHash["[em闹钟]"]="23f0.png";this.emojiHash["[em饭团]"]="1f359.png";this.emojiHash["[em糯米团]"]="1f361.png";this.emojiHash["[em松木纹饰]"]="1f38d.png";this.emojiHash["[em手机关机]"]="1f4f4.png";this.emojiHash["[em高速列车]"]="1f684.png";this.emojiHash["[em黑框]"]="25fc.png";this.emojiHash["[em西班牙国旗]"]="1f1ea-1f1f8.png";this.emojiHash["[em自然]"]="1f303.png";this.emojiHash["[em三角1]"]="25c0.png";this.emojiHash["[em右箭头]"]="27a1.png";this.emojiHash["[em悠闲]"]="263a.png";this.emojiHash["[em_black_joker]"]="1f0cf.png";this.emojiHash["[em滑雪]"]="1f3bf.png";this.emojiHash["[em低亮度符号]"]="1f505.png";this.emojiHash["[em亲吻]"]="1f48f.png";this.emojiHash["[em游泳]"]="1f3ca.png";this.emojiHash["[em困倦]"]="1f62a.png";this.emojiHash["[em戒指]"]="1f48d.png";this.emojiHash["[em双大环]"]="27bf.png";this.emojiHash["[打哈气]"]="36.gif";this.emojiHash["[em吻]"]="1f617.png";this.emojiHash["[em开花]"]="1f33c.png";this.emojiHash["[em棒棒糖]"]="1f36d.png";this.emojiHash["[em榄球]"]="1f3c9.png";this.emojiHash["[em电插头]"]="1f50c.png";this.emojiHash["[em开锁]"]="1f513.png";this.emojiHash["[em邮政号角]"]="1f4ef.png";this.emojiHash["[em星光]"]="1f31f.png";this.emojiHash["[em玉米]"]="1f33d.png";this.emojiHash["[em#号]"]="0023-20e3.png";this.emojiHash["[em_abc]"]="1f524.png";this.emojiHash["[em有装饰盖的笔记本]"]="1f4d4.png";this.emojiHash["[em圆图钉]"]="1f4cd.png";this.emojiHash["[em老虎机]"]="1f3b0.png";this.emojiHash["[em12点半]"]="1f567.png";this.emojiHash["[em花扑克牌]"]="1f3b4.png";this.emojiHash["[x打招呼]"]="x3.gif";this.emojiHash["[em苹果]"]="1f34e.png";this.emojiHash["[em牛仔裤]"]="1f456.png";this.emojiHash["[em夜间大桥]"]="1f309.png";this.emojiHash["[em刨冰]"]="1f367.png";this.emojiHash["[em全球网络]"]="1f310.png";this.emojiHash["[拜拜]"]="41.gif";this.emojiHash["[em美元]"]="1f4b5.png";this.emojiHash["[em心装饰]"]="1f49f.png";this.emojiHash["[em_wavy_dash]"]="3030.png";this.emojiHash["[em双三角UP]"]="23eb.png";this.emojiHash["[em三角2]"]="25b6.png";this.emojiHash["[em10点半]"]="1f565.png";this.emojiHash["[em6点]"]="1f555.png";this.emojiHash["[em苦笑猫]"]="1f63c.png";this.emojiHash["[em划艇]"]="1f6a3.png";this.emojiHash["[em警车]"]="1f693.png";this.emojiHash["[em上下箭头]"]="2195.png";this.emojiHash["[em纸]"]="1f4df.png";this.emojiHash["[em直尺]"]="1f4cf.png";this.emojiHash["[em总账]"]="1f4d2.png";this.emojiHash["[em电视机]"]="1f4fa.png";this.emojiHash["[em_inbox_tray]"]="1f4e5.png";this.emojiHash["[x不知道]"]="x2.gif";this.emojiHash["[怒]"]="38.gif";this.emojiHash["[em_hatched_chick]"]="1f425.png";this.emojiHash["[em巧克力]"]="1f36b.png";this.emojiHash["[em非洲地球]"]="1f30d.png";this.emojiHash["[em轮椅]"]="267f.png";this.emojiHash["[em新]"]="1f195.png";this.emojiHash["[em无口]"]="1f636.png";this.emojiHash["[em甜甜圈]"]="1f369.png";this.emojiHash["[怒骂]"]="57.gif";this.emojiHash["[em视频摄像机]"]="1f4f9.png";this.emojiHash["[em笑脸角]"]="1f608.png";this.emojiHash["[em撕下日历]"]="1f4c6.png";this.emojiHash["[em交叉标志]"]="1f38c.png";this.emojiHash["[em铅笔]"]="270f.png";this.emojiHash["[em_no_bell]"]="1f515.png";this.emojiHash["[emT-SHIRT]"]="1f455.png";this.emojiHash["[给力]"]="3.gif";this.emojiHash["[呵呵]"]="12.gif";this.emojiHash["[em汉堡包]"]="1f354.png";this.emojiHash["[em天秤座]"]="264e.png";this.emojiHash["[赞]"]="65.gif";this.emojiHash["[em红唇]"]="1f48b.png";this.emojiHash["[em多音符]"]="1f3b6.png";this.emojiHash["[em黄心]"]="1f49b.png";this.emojiHash["[兔子]"]="7.gif";this.emojiHash["[em五彩纸屑球]"]="1f38a.png";this.emojiHash["[em板栗]"]="1f330.png";this.emojiHash["[em移动电话]"]="1f4f1.png";this.emojiHash["[em草莓]"]="1f353.png";this.emojiHash["[em包头巾]"]="1f473.png";this.emojiHash["[em德国国旗]"]="1f1e9-1f1ea.png";this.emojiHash["[em油爆虾]"]="1f364.png";this.emojiHash["[em数字9]"]="0039-20e3.png";this.emojiHash["[em6点半]"]="1f561.png";this.emojiHash["[em山羊]"]="1f410.png";this.emojiHash["[em假名KOKO]"]="1f201.png";this.emojiHash["[em单板滑雪]"]="1f3c2.png";this.emojiHash["[em软盘]"]="1f4be.png";this.emojiHash["[em口红]"]="1f484.png";this.emojiHash["[em太阳]"]="2600.png";this.emojiHash["[委屈]"]="34.gif";this.emojiHash["[em牵手的女人]"]="1f46d.png";this.emojiHash["[em跳舞]"]="1f483.png";this.emojiHash["[em施工]"]="1f6a7.png";this.emojiHash["[em英镑]"]="1f4b7.png";this.emojiHash["[em螺母螺栓]"]="1f529.png";this.emojiHash["[em信封]"]="2709.png";this.emojiHash["[em数字8]"]="0038-20e3.png";this.emojiHash["[懒得理你]"]="29.gif";this.emojiHash["[哈哈]"]="14.gif";this.emojiHash["[em公文包]"]="1f4bc.png";this.emojiHash["[em强壮]"]="1f4aa.png";this.emojiHash["[em糖果]"]="1f36c.png";this.emojiHash["[em老奶奶]"]="1f475.png";this.emojiHash["[em飞机]"]="2708.png";this.emojiHash["[em意大利面条]"]="1f35d.png";this.emojiHash["[em情侣]"]="1f46b.png";this.emojiHash["[em锁定]"]="1f512.png";this.emojiHash["[em满意]"]="1f606.png";this.emojiHash["[em钥匙]"]="1f511.png";this.emojiHash["[em疲倦]"]="1f62b.png";this.emojiHash["[em满]"]="1f235.png";this.emojiHash["[em心情]"]="1f4a2.png";this.emojiHash["[em预定]"]="1f22f.png";this.emojiHash["[em雰]"]="1f301.png";this.emojiHash["[x害怕]"]="x6.gif";this.emojiHash["[em热气腾腾]"]="1f372.png";this.emojiHash["[em场记板]"]="1f3ac.png";this.emojiHash["[em三角尺]"]="1f4d0.png";this.emojiHash["[em章鱼]"]="1f419.png";this.emojiHash["[em哭泣]"]="1f622.png";this.emojiHash["[馋嘴]"]="40.gif";this.emojiHash["[em左行李]"]="1f6c5.png";this.emojiHash["[em面无表情]"]="1f611.png";this.emojiHash["[em灯笼]"]="1f3ee.png";this.emojiHash["[em建筑工人]"]="1f477.png";this.emojiHash["[em地铁]"]="1f687.png";this.emojiHash["[em眼镜]"]="1f453.png";this.emojiHash["[em消防车]"]="1f692.png";this.emojiHash["[em公共汽车站]"]="1f68f.png";this.emojiHash["[x生气]"]="x13.gif";this.emojiHash["[em绿书]"]="1f4d7.png";this.emojiHash["[em火山]"]="1f30b.png";this.emojiHash["[em医院]"]="1f3e5.png";this.emojiHash["[x看我的]"]="x11.gif";this.emojiHash["[em运动鞋]"]="1f45f.png";this.emojiHash["[em蛋糕]"]="1f370.png";this.emojiHash["[em蜜蜂]"]="1f41d.png";this.emojiHash["[浮云]"]="2.gif";this.emojiHash["[em白小框1]"]="25ab.png";this.emojiHash["[em恐怖]"]="1f631.png";this.emojiHash["[em_arrow_up_small]"]="1f53c.png";this.emojiHash["[em玫瑰]"]="1f339.png";this.emojiHash["[em思维气球]"]="1f4ad.png";this.emojiHash["[em戴面纱新娘]"]="1f470.png";this.emojiHash["[em_back]"]="1f519.png";this.emojiHash["[em奖杯]"]="1f3c6.png";this.emojiHash["[em快艇]"]="1f6a4.png";this.emojiHash["[em广播]"]="1f4e2.png";this.emojiHash["[em萨克斯]"]="1f3b7.png";this.emojiHash["[生病]"]="27.gif";this.emojiHash["[em耳朵]"]="1f442.png";this.emojiHash["[害羞]"]="19.gif";this.emojiHash["[em愁眉苦脸]"]="1f64d.png";this.emojiHash["[em爱情旅馆]"]="1f3e9.png";this.emojiHash["[em碰杯]"]="1f37b.png";this.emojiHash["[x喝彩]"]="x8.gif";this.emojiHash["[em领带]"]="1f454.png";this.emojiHash["[x不屑]"]="x0.gif";this.emojiHash["[em狼]"]="1f43a.png";this.emojiHash["[em毛毛虫]"]="1f41b.png";this.emojiHash["[em狮子狗]"]="1f429.png";this.emojiHash["[em水晶球]"]="1f52e.png";this.emojiHash["[em摩天轮]"]="1f3a1.png";this.emojiHash["[em甲虫]"]="1f41e.png";this.emojiHash["[em中等白圈]"]="26aa.png";this.emojiHash["[em七夕树]"]="1f38b.png";this.emojiHash["[em_SOS]"]="1f198.png";this.emojiHash["[em禁止行人]"]="1f6b7.png";this.emojiHash["[em拳头]"]="1f44a.png";this.emojiHash["[em双感叹号]"]="203c.png";this.emojiHash["[em云背后的太阳]"]="26c5.png";this.emojiHash["[em感叹号]"]="2755.png";this.emojiHash["[em猪头]"]="1f437.png";this.emojiHash["[em鱼饼]"]="1f365.png";this.emojiHash["[em日历]"]="1f4c5.png";this.emojiHash["[em卡舌头]"]="1f61b.png";this.emojiHash["[em黑小框]"]="25fe.png";this.emojiHash["[em输入符号]"]="1f523.png";this.emojiHash["[em举手]"]="1f64b.png";this.emojiHash["[em笑嘻嘻]"]="1f601.png";this.emojiHash["[em月亮]"]="1f319.png";this.emojiHash["[em菠萝]"]="1f34d.png";this.emojiHash["[em过山车]"]="1f3a2.png";this.emojiHash["[em_soon]"]="1f51c.png";this.emojiHash["[em十八禁]"]="1f51e.png";this.emojiHash["[em_arrows_clockwise]"]="1f503.png";this.emojiHash["[威武]"]="5.gif";this.emojiHash["[em鳄鱼]"]="1f40a.png";this.emojiHash["[em西红柿]"]="1f345.png";this.emojiHash["[em喇叭]"]="1f3ba.png";this.emojiHash["[em牧羊座]"]="2648.png";this.emojiHash["[em狮子座]"]="264c.png";this.emojiHash["[em怪兽]"]="1f47e.png";this.emojiHash["[em票据]"]="1f3ab.png";this.emojiHash["[汗]"]="43.gif";this.emojiHash["[em冲浪]"]="1f3c4.png";this.emojiHash["[em注射器]"]="1f489.png";this.emojiHash["[em恶魔]"]="1f47f.png";this.emojiHash["[困]"]="44.gif";this.emojiHash["[em绵羊]"]="1f411.png";this.emojiHash["[em搜索]"]="1f50d.png";this.emojiHash["[em2点半]"]="1f55d.png";this.emojiHash["[em_on]"]="1f51b.png";this.emojiHash["[em方块]"]="2666.png";this.emojiHash["[em语音气球]"]="1f4ac.png";this.emojiHash["[em眨眼]"]="1f609.png";this.emojiHash["[em汗水]"]="1f4a6.png";this.emojiHash["[em婴儿奶瓶]"]="1f37c.png";this.emojiHash["[钟]"]="69.gif";this.emojiHash["[em疲倦猫]"]="1f640.png";this.emojiHash["[em烤地瓜]"]="1f360.png";this.emojiHash["[em米饭]"]="1f35a.png";this.emojiHash["[em手电筒]"]="1f526.png";this.emojiHash["[em常绿树]"]="1f332.png";this.emojiHash["[em_incoming_envelope]"]="1f4e8.png";this.emojiHash["[em帐篷]"]="26fa.png";this.emojiHash["[em乘]"]="2716.png";this.emojiHash["[em_tram_car]"]="1f68b.png";this.emojiHash["[em大笑]"]="1f602.png";this.emojiHash["[ok]"]="61.gif";this.emojiHash["[em失望~汗]"]="1f625.png";this.emojiHash["[em自行车]"]="1f6b2.png";this.emojiHash["[em花朵]"]="1f33a.png";this.emojiHash["[em耳机]"]="1f3a7.png";this.emojiHash["[em感叹号问号]"]="2049.png";this.emojiHash["[em困惑]"]="1f616.png";this.emojiHash["[em男孩]"]="1f466.png";
		//<li><a title="[织]"   href="javascript:;"><img src=" "></a></li>
	},
	getFaceImg:function(gif){
		return  this.imgbase+"imface/common/"+gif;
	},
	addFaces:function(){
		if(this.faceHash.src){
			for(var i=0;i<this.faceHash.src.length;i++){
				$(".wbim_face_list").append('<li><a title="'+this.faceHash.src[i]+'"   href="javascript:;"><img src="'+this.getFaceImg(i+".gif")+'"></a></li>');
			}
			$(".wbim_face_list li a img").click(function(event){
				var e=$(".wbim_chat_input textarea"); 
				e.val(e.val()+$(event.target).parent().attr("title"));
				$(".wbim_face_box").hide();
			});
			this.faceHash.src=null;
		}
	},

	regEvents : function() {
		
		
		this.minBox = $(".wbim_min_box_col2");
		this.chatList = $("ul.wbim_chat_friend_list");
		this.chatConentList=$(".wbim_chat_list");// 获取聊天记录
		this.minChat=$(".wbim_min_chat");

		// 提示条
		$(".wbim_chat_tips .wbim_icon_close_s").click(function() {
			IM.hiddeOffLineTips();
		});
		// 关闭聊天窗口
		$(".wbim_chat_box * .wbim_tit_rt a.wbim_icon_close").click(function() {
			IM.closeChatWindow();
		});
		// 最小化聊天窗口
		$(".wbim_chat_box * a.wbim_icon_mini").click(function() {
			IM.minChatWindow();
		});
		// 最大化聊天窗口
		$(".wbim_min_chat").click(function() {
			if($(".wbim_min_nick ").text().indexOf("离线消息")>0){
				IM.cookie("DZQ_MSGC", 0);
				IM.minChat.removeClass("wbim_min_chat_msg");
				location= IM.msgurl; 
				return;
			}
			
			IM.maxChatWinow();
		});
		
		$(".wbim_send_pmsg").attr("url",this.msgurl);

		// 最小化列表窗口
		$(".wbim_list_expand * .wbim_icon_mini").click(function() {
			IM.minListWinow();
		});
		$(".wbim_clicknone").click(function() {
			IM.minListWinow();
		});

		// 最大化列表窗口
		$(".wbim_min_friend").click(function() {
			IM.maxListWinow();
		});
		
		//打开表情
		/*$(".wbim_tool_ctrl").click(function(){
			IM.addFaces();
			$(".wbim_face_box").show();
		});*/
		//打开表情
		$("#wbim-face-upload").click(function(){
			IM.addFaces();
			$(".wbim_face_box").show();
		});
		$("#fileToUpload-webim").uploadify({
			fileTypeDesc : '图片文件',
	        fileTypeExts : '*.gif; *.jpg; *.png;*.jpeg;*.bmp', 
			buttonText:'图片',
			fileObjName:'file',
			multi:'false',
			height        : 15,
			swf           : IM.webroot+'/js/uploadify.swf',
			uploader      : IM.webroot+'/party/fileUploadAction!uploadFile.action',
			width         : 30,
			'onUploadSuccess' : function(file, data, response) {
	            var _data = eval('(' + data + ')');
	            if(_data.result == 1){
	        		IM.sendMsg(_data.fileName,1);
	        	}
	        } ,
	        'onInit': function () {//载入时触发，将flash设置到最小，隐藏上传进度条
	            $("#fileToUpload-webim-queue").hide();
	         }
		});
		//文件上传
		$("#wbim-file-upload").click(function(){
			//$("#uploadImg").click();
		});
		//关闭表情
		$(".wbim_face_tit .wbim_icon_close").click(function(){
			$(".wbim_face_box").hide();
		});
		
		//状态切换菜单
		$("div.wbim_tit_lf div div.tit").click(function(event){
			//暂时隐藏
			$("div.wbim_tit_lf div ul").show();
		});
		$("#searchFriend").keyup(function(e){
			IM.searchFriend($(this).val());
		});
		$("div.wbim_tit_lf div ul li a").click(function(e){
			$("div.wbim_tit_lf div ul").hide();
			IM.setStatus($(this));
		});
		//朋友组展开和收起
		var frdlg=$("#wbim_list_group_frd div");
		frdlg.click(function(){
			frdlg.toggleClass("wbim_close");
			$("#wbim_list_group_frd ul").toggle();
		});
		//群组展开和收起
		var grouplg=$("#wbim_list_group_group div");
		grouplg.click(function(){
			grouplg.toggleClass("wbim_close");
			$("#wbim_list_group_group ul").toggle();
		});		
		
		function texthandler(event){
			var e=$(".wbim_chat_input textarea");
			var leng= $.trim(e.val()).length;
			if ( event.which == 13 &&(!IM.needCtl||event.ctrlKey) ) {
			    
			    
			     if(leng<200&&leng>0){
			 		IM.sendMsg(e.val());
			 		e.val("");
			 		 leng=0;
			     }
			     event.preventDefault();
			  }
			
			
			 $(".wbim_chat_btm_rt .wbim_tips_char span:first-child").text(200-leng);
		};
		
		//增加键盘
		var t=$(".wbim_chat_input textarea");
		t.keyup(texthandler );
		t.bind('cut paste change',texthandler );
		 
		
		
		
		//发送按钮
		$(".wbim_btn_publish").click(function(){
			texthandler({"which":13,preventDefault:function(){},"ctrlKey":true});
		});
		//选择如何发送的方式
		var chmenu=$(".wbim_box .wbim_btn_choose ul");
		$(".wbim_box .wbim_btn_choose_a").click(function(){
			chmenu.fadeToggle();
		});
		var esl=$('li[node-type="wbim_enter_send_li"]');
		var csl=$('li[node-type="wbim_ctrlenter_send_li"]');
		
		esl.click(function(){
			esl.attr("class","curr");
			csl.attr("class","");			
			IM.needCtl=false;
			chmenu.fadeToggle();
			IM.setLocalStorage("sendType", "enter");
		});
		csl.click(function(){
			esl.attr("class","");
			csl.attr("class","curr");	
			IM.needCtl=true;
			chmenu.fadeToggle();
			IM.setLocalStorage("sendType", "ctrlenter");
		});
		
		//$(".wbim_face").hide();
		$(".wbim_face:first-child").show();
		
		
	},
	setStatus:function(statusStr){
		//取选中的状态的值和样式
		var _txt = statusStr.text();
		var _c = statusStr.children()[0].className;
		//取第一个span，设置样式
		var _firstChild = $($($("div.wbim_tit_lf div div.tit").children()).get(0));
		_firstChild.removeClass();
		_firstChild.addClass(_c);
		//取第二个span，设置值
		var _secondeChild = $($($("div.wbim_tit_lf div div.tit").children()).get(1));
		_secondeChild.text(_txt);
		//$("div.wbim_tit_lf div div.tit").firstChild().addClass("wbim_status_busy");
	},
	removeShine:function(e){
		for(var i=0;i<this.shines.length;i++){
			var a=this.shines[i];
			if(a&&(a==e||a.attr("uid")==e.attr("uid"))){
				a.removeClass("wbim_highlight_shine");
				this.shines[i]=null;
				
				return;
			}
		}
	},
	/**
	 * 初始化
	 * @param uid 当前用户ID
	 */
	init : function(uid) {
		this.userId=parseInt(uid);
		this.lid=this.cookie("LID" );
		if(this.userId&&this.userId>0){
			var grouop = '';
			var htmlVar = '<div id="wbim_box" class="wbim_box" style="position: fixed; bottom: 0px; right: 20px;"> <div class="wbim_list_expand" style="z-index: 1001; right: 0px; bottom: 0px;display:none"> <div class="wbim_list_con"> <div class="wbim_tit"> <div class="wbim_titin"> <div class="wbim_tit_lf"> <div node-type="status_manager"> <div class="tit"> <span class="wbim_status_online"></span><span class="txt">在线</span><span class="icon"></span> </div> <div class="linert"></div> <ul style="display: none;"> <li class="lingtop"></li> <li><a href="javascript:void(0)"><span class="wbim_status_online"></span>在线</a></li> <li><a href="javascript:void(0)"><span class="wbim_status_busy"></span>忙碌</a></li> <li><a href="javascript:void(0)"><span class="wbim_status_away"></span>离开</a></li> <li><a href="javascript:void(0)"><span class="wbim_status_offline"></span>隐身</a></li> </ul> </div> </div> <div class="wbim_tit_rt"> <a href="javascript:;" class="wbim_icon_mini" title="最小化" hidefocus="true" suda-uatrack="key=tblog_webim_behavior&amp;value=click_mini_button"></a> </div> </div> </div> <div class="wbim_line"></div> <div class="wbim_list_up"> <div class="wbim_list_srch"> <div class="wbim_list_srchin"> <a class="wbim_icon_close_s" style="display: none;" hidefocus="true" href="javascript:void(0)" suda-uatrack="key=tblog_webim_behavior&amp;value=click_empty_button"></a><input id="searchFriend" type="text" placeholder="查找好友"> </div> </div> </div> <div class="wbim_list_tab"></div> <div class="wbim_list_box"> <div class="wbim_list_friend"> <div class="wbim_list_group" id="wbim_list_group_frd"> <div class="wbim_list_group_tit wbim_open" action-type="UserGroup.Onclick" action-data="id=normalusernogroup" title="我的好友"> 我的好友 [ <span title="在线好友">0</span> ] </div> <ul style=""> </ul> </div> </div> <div class="wbim_list_friend"><div id="wbim_list_group_group" class="wbim_list_group"><div class="wbim_list_group_tit wbim_open" title="我的群组" action-data="id=normalusernogroup" action-type="UserGroup.Onclick">我的群组</div><ul style=""></ui></div></div> </div> <div class="wbim_list_pos"> <a class="wbim_clicknone" hidefocus="true" href="javascript:;" suda-uatrack="key=tblog_webim_behavior&amp;value=click_bottom_button"><span class="wbim_icon_arrd"></span></a> <div class="wbim_send_con" title="查看我的私信"> <a class="wbim_send_pmsg" hidefocus="true" target="_blank" href="/wenda/notify/msg.action"><span class="wbim_btn_smesg"></span></a> </div> </div> </div> </div> <div class="wbim_chat_box " style="position: absolute; right: 199px; bottom: 0px; z-index: 1001; display: none;" node-type="wbim_chat_box"> <div class="wbim_chat_con" node-type="wbim_chat_con"> <div class="wbim_tit" node-type="wbim_tit"> <div class="wbim_titin" node-type="wbim_titin"> <div class="wbim_tit_lf"> <p node-type="wbim_single_user"  > <span node-type="wbim_status" class="wbim_status_offline"></span><span class="txt"><a target="_blank" node-type="wbim_tit_lf_name"  title="" href="#"></a></span><span style="display: none;" class="bringin" node-type="wbim_tit_lf_count">正在输入</span> </p> <p style="display: none;" node-type="wbim_group"> <span class="wbim_icon_group_tit"></span><span class="txt"><a target="_blank" node-type="wbim_tit_lf_gname"></a><em class="txtg">在线成员(<a title="查看在线成员" node-type="group_num" target="_blank" suda-uatrack="key=tblog_webim_behavior&amp;value=click_online_friends"></a>) </em></span> </p> </div> <div class="wbim_tit_rt"> <a href="javascript:;" class="wbim_icon_mini" hidefocus="true" title="最小化" node-type="wbim_icon_mini"></a><a href="javascript:;" class="wbim_icon_close" hidefocus="true" title="关闭" node-type="wbim_icon_close"></a> </div> </div> </div> <div node-type="wbim_mask" style="display: none; position: absolute; top: 24px; right: 316px; z-index: 1002;"> <div style="width: 316px; height: 365px;" class="wbim_box_pop"></div> <div class="wbim_confirm_box" style="top: 145px; left: 50px;"> <div class="wbim_confirm_info"> <p class="wbim_confirm_p"> <span class="wbim_icon_tips"></span><span class="txt" node-type="txt"></span> </p> <p class="wbim_confirm_btn"> <a class="wbim_btn_c" node-type="wbim_btn_c" href="javascript:;" hidefocus="true"><em>确定</em></a> </p> </div> </div> </div> <div class="wbim_chat_lf" node-type="wbim_chat_lf" style="visibility: visible;"> <a class="wbim_scrolltop_n" node-type="wbim_scrolltop" hidefocus="true" href="javascript:;" onclick="return false;"></a> <div class="wbim_chat_friend_box"> <ul class="wbim_chat_friend_list" node-type="wbim_chat_friend_list"> </ul> </div> <a class="wbim_scrollbtm_n" node-type="wbim_scrollbtm" hidefocus="true" href="javascript:;" onclick="return false;"></a> </div> <div class="wbim_chat_rt"> <div class="wbim_chat_up"> <div class="wbim_chat_tips" node-type="wbim_chat_tips" style="display: block;"> <span class="wbim_icon_tips"></span><span node-type="wbim_chat_tips_content"></span><a hidefocus="true" href="javascript:;" node-type="wbim_icon_close_s" class="wbim_icon_close_s"></a> </div> <div class="wbim_chat_list" style="height: 198px; top: 24px;"> </div> </div> <div class="wbim_chat_toolbar" node-type="wbim_chat_toolbar"> <div class="wbim_chat_toolbarin" node-type="wbim_chat_toolbarin"> <div class="wbim_face" node-type="wbim_face" style="margin: 7px 0 0;"> <a class="wbim_tool_ctrl" id="wbim-face-upload" title="普通表情" node-type="wbim_icon_face" hidefocus="true" href="javascript:;" ><i class="wbim_icon_face" style="margin-bottom: 3px;"></i><span style="margin-bottom:0px;">表情</span></a> <div class="wbim_face_box" style="display: none;" node-type="wbim_face_box"> <div class="wbim_face_tit"> <div class="wbim_face_arr"></div> <div class="wbim_face_tit_lf">普通表情</div> <a class="wbim_icon_close" href="javascript:;" node-type="wbim_icon_close"></a> </div> <div class="wbim_face_con"> <ul class="wbim_face_list" node-type="wbim_face_list"></ul> <div class="tsina_loading cter"> <span class="tsina_ico_ldg"></span> </div> </div> </div> </div> <div title="上传图片" style="margin-top:7px" class="wbim_face"> <a href="#" hidefocus="true" class="wbim_tool_ctrl" id="wbim-image-upload"><i class="wbim_icon_img"></i><i style="display: inline-block;"><input id="fileToUpload-webim" name="file" type="file"/></i></a> </div> <div title="上传文件" class="wbim_face" style="display:none"> <a href="javascript:;" hidefocus="true" class="wbim_tool_ctrl" id="wbim-file-upload"><i class="wbim_icon_doc"></i>文件</a> </div> <a hidefocus="true" href="javascript:;" class="wbim_icon_group" style="margin-left: 10px; display: none;"></a><a class="wbim_history" style=""   title="私信记录" target="_self" suda-uatrack="key=tblog_webim_behavior&amp;value=click_chats_button" href="http://weibo.com/message/talklist.php?source=webim&amp;uid=1163688452"><span class="wbim_icon_chatdoc"></span>私信记录</a><a class="wbim_history" style="display: none;" node-type="wbim_history_group" title="聊天记录" target="_blank" suda-uatrack="key=tblog_webim_behavior&amp;value=click_chats_button"><span class="wbim_icon_chatdoc"></span>聊天记录</a> </div> </div> <div class="wbim_chat_input" node-type="wbim_chat_input" style="margin-top: 1px;"> <div class="wbim_chat_input_tips" node-type="root" style="display: none;"> <div class="wbim_tips_pos_n" node-type="wbim_tips_pic" style="display: none;"> <div class="wbim_tips_pic_n"> <a href="javascript:;"><img node-type="img_preview" alt="" action-type="wbim_img_preview" style="cursor: pointer"></a> </div> <span class="wbim_p_arr"></span> </div> <div class="fl" node-type="fl"></div> <div class="fr" node-type="fr"></div> </div> <textarea node-type="wbim_chat_input_ta"></textarea> </div> <div class="wbim_chat_btm" node-type="wbim_chat_btm"> <div class="wbim_chat_btmin"> <div class="wbim_chat_btm_lf"></div> <div class="wbim_chat_btm_rt"> <p class="wbim_tips_char"> <span node-type="wbim_tips_char">200</span><span class="spetxt" node-type="spetxt"></span> </p> <div class="wbim_btn_send" node-type="wbim_btn_send"> <a hidefocus="true" node-type="wbim_btn_publish" class="wbim_btn_publish" href="javascript:;" title="发送">发送</a> <div class="wbim_btn_choose"> <a node-type="wbim_btn_choose_a" class="wbim_btn_choose_a">选择</a> <ul node-type="wbim_btn_choose"> <li class=" " node-type="wbim_enter_send_li"><span></span><em><a href="javascript:;" node-type="wbim_enter_send">按Enter键发送</a></em></li> <li class="line"><span></span><em></em></li> <li node-type="wbim_ctrlenter_send_li" class=" curr"><span></span><em><a href="javascript:;" node-type="wbim_ctrlenter_send">按Ctrl+Enter键发送</a></em></li> </ul> </div> </div> </div> </div> </div> </div><div class="wbim_chat_ef" style="display:none" node-type="wbim_chat_ef"><div id="wbim_member" class="wbim_member" ><div style="background-color:#EBEBEB;text-align:center">群成员</div><ul></ul></div></div> </div> <div style="left: 130px; z-index: 100; top: 150px; position: absolute; display: none;" node-type="wbim_confirm_box"> <div class="wbim_confirm_box"> <div class="wbim_confirm_con"> <div class="wbim_confirm_info"> <p class="wbim_confirm_p"> <span class="wbim_icon_ask"></span><span class="txt">提示：关闭会话窗口后，其中的未读私信将不再重复提醒。</span> </p> <p class="wbim_confirm_btn"> <a href="javascript:;" class="wbim_btn_c" node-type="wbim_btn_c"><em>确认</em></a><a href="javascript:;" class="wbim_btn_n" node-type="wbim_btn_n"><em>取消</em></a> </p> </div> </div> </div> <div style="position: absolute; width: 420px; height: 365px; top: -126px; left: -130px;" class="wbim_box_pop" node-type="wbim_box_pop"></div> </div> </div> <div class="wbim_min_box_col2" style="position: absolute; bottom: 0px; right: 0px;"> <div class="wbim_min_box"> <div class="wbim_min_friend"> <p class="statusbox"> <span class="wbim_status_online"></span> </p> 私信聊天 [ <span title="在线联系人" class="wbim_online_count">0</span> ]<span class="webim_rec_count" style="display: none; color: gray; margin-left: 80px;"></span> </div> <div class="wbim_min_line wbim_min_linefor3"></div> <div class="wbim_min_chat"> <span class="wbim_icon_msg"></span><span class="wbim_min_text_pre"></span><span class="wbim_min_nick" suda-uatrack="key=tblog_webim_behavior&amp;value=click_unread_message"></span><span class="line"></span><span class="wbim_min_text"></span> </div> </div> </div>  <bgsound loop="1" class="webim_msg_sd"/>  </div>';
			$("body").append(htmlVar);
			this.initFace();
			this.regEvents();// 添加事件监听
			this.fetchList();// 获取好友列表
			this.chatList.empty();// 清空聊天列表
			this.shineloop();
			this.fetchGroupList();//群组列表
			this.initTools();
			//this.pull();// 发送请求
			//防止firefox状态栏等待
			
			$(document).ready(function() {
				setTimeout(function(){
					IM.pull();
				},1000);
				
			});
			
			$("#wbim_box").contextmenu(function(){
				return false;
			});
			if((typeof IMAfterInit) =='function'){
				try{
				eval("IMAfterInit()");
				}catch(e){
					alert("外部初始化失败："+e.message)
				}
			}
		}
		
		
	},
	/**
	 * 初始化发送类型，将用户设置的发送类型保存在本地
	 */
	initTools:function(){
		//选择如何发送的方式
		var chmenu=$(".wbim_box .wbim_btn_choose ul");
		var esl=$('li[node-type="wbim_enter_send_li"]');
		var csl=$('li[node-type="wbim_ctrlenter_send_li"]');
		var storage = window.localStorage;
		if(storage){
			var _type = storage.getItem("sendType");
			if("enter"==_type){
				esl.attr("class","curr");
				csl.attr("class","");			
				IM.needCtl=false;
				chmenu.hide();
			}else if("ctrlenter"==_type){
				esl.attr("class","");
				csl.attr("class","curr");	
				IM.needCtl=true;
				chmenu.hide();
			}
		}
	},
	/**
	 * 设置本地缓存
	 */
	setLocalStorage:function(k,v){
		var storage = window.localStorage;
		if(storage){
			storage.setItem(k,v);
		}
	},
	/**
	 * 通过键取本地缓存的数据
	 */
	getLocalStorage:function(k){
		var storage = window.localStorage;
		if(storage){
			storage.getItem(k);
		}
	},
	shineloop:function(){
		for(var i=0;i<IM.shines.length;i++){
			var a=IM.shines[i];
			if(a)
			a.toggleClass("wbim_highlight_shine");
		};
		setTimeout(IM.shineloop,500);
	},

	/*
	 *  时间格式化
	 *  @param formatStr eg:y年m月d日 h:M:S
	 */
	formatTime:function (formatStr) {
		var date = new Date();
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		var d = date.getDate();
		var h = date.getHours();
		var M = date.getMinutes();
		var S = date.getSeconds();
		m = m < 10 ? "0" + m : m;
		d = d < 10 ? "0" + d : d;
		h = h < 10 ? "0" + h : h;
		M = M < 10 ? "0" + M : M;
		S = S < 10 ? "0" + S : S;
		return formatStr.replace("y", y).replace("m", m).replace("d", d).replace("h", h).replace("M", M).replace("S", S);
	},
	 
	//////////////
	cookie: function(name, value) {
		    if (typeof value != 'undefined') { // name and value given, set cookie
		         document.cookie = [name, '=', encodeURIComponent(value),"; path=/"].join('');
		    } else { // only name given, get cookie
		        var cookieValue = null;
		        if (document.cookie && document.cookie != '') {
		            var cookies = document.cookie.split(';');
		            for (var i = 0; i < cookies.length; i++) {
		                var cookie = jQuery.trim(cookies[i]);
		                // Does this cookie string begin with the name we want?
		                if (cookie.substring(0, name.length + 1) == (name + '=')) {
		                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
		                    break;
		                }
		            }
		        }
		        return cookieValue;
		    }
		}
	 
	
	
};

function getMsgDiv(dumm,uid,uname){
	IM.chatTo(uid);
}
function showMsgWin(from,name,uid){
	IM.chatTo(uid);
}
function updateMsgCnt(){
	
}
/*
	$(document).ready(function() {
		IM.init(1100);
	})
*/
